<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title> 文献医案编辑 </title>
  <link rel="stylesheet" type="text/css" href="/css/style.css" />
  <link rel="stylesheet" type="text/css" href="/css/stars.css" />
  <!-- OCR识别 -->
  <script src="/tesseract.js-offline-master/node_modules/tesseract.js/dist/tesseract.min.js"></script>
  <script src="/js/jquery-3.6.0.min.js"></script>
  <style type="text/css">
    *,
    body {
      margin: 0px;
      font-family: '微软雅黑', serif;
    }


    .core {
      height: 400px;
      width: 1000px;
      margin: 0 auto;
    }

    .core .source {
      float: left;
      width: 480px;
      margin: 0 10px;
    }

    .core .source #imgPreview {
      width: 480px;
      height: 298px;
    }

    .core .result {
      float: left;
      width: 480px;
      margin: 0 10px;
    }

    .core .result #resultMsg {
      width: 480px;
      height: 298px;

    }
    #previewContainer {
      display: none;
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background-color: white;
      padding: 20px;
      border: 1px solid #ccc;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
      z-index: 999;
    }
    .cankaoTable{
      border: 1px solid black;
      padding: 8px;
      text-align: center;
      vertical-align: middle; /* 居中整个单元格的内容 */
    }
    .tianjiafangjidiv > *{
      margin: 0;
    }
    .tianjiafangjidiv {
      padding: 0;
    }
    .previewImage {
      max-width: 500px; /* 设置图像最大宽度 */
      max-height: 500px; /* 设置图像最大高度 */
    }

    /* 使用媒体查询在页面宽度较小时调整图像大小 */
    @media (max-width: 800px) {
      .previewImage {
        max-width: 100%; /* 设置图像最大宽度为页面宽度的 100% */
      }
    }
  </style>
  <script src="/js/jquery-1.10.2.min.js"></script>
  <script src="/js/jquery.form.js"></script>
  <script src="/js/generic.js"></script>

  <script type="text/javascript" src="/js/EasyUI/jquery.ui.widget.js"></script>
  <script type="text/javascript" src="/js/EasyUI/jquery.iframe-transport.js"></script>
  <script type="text/javascript" src="/js/EasyUI/jquery.fileupload.js"></script>
  <script type="text/javascript" src="/js/EasyUI/jquery.fileupload-process.js"></script>
  <script type="text/javascript" src="/js/EasyUI/jquery.fileupload-validate.js"></script>
  <script type="text/javascript" src="/js/EasyUI/jquery.fileupload-ui.js"></script>
</head>

<body>

  <form id="filePost" method="post" enctype="multipart/form-data" onsubmit="return false;">
    <table class="maintable">
      <tr>
        <td class="rightmaintd" valign="top">
          <div class="searchdiv">
            <a href="/wxya">&lt; 返回</a> &nbsp; &nbsp; &nbsp; &nbsp;
            <div class="rightsearchdiv"><!-- name --></div>
          </div>

          <div class="searchdiv" style="display:none" id="trPreView">
            <input type="button" value="病例预览" class="xinzengbtn" onclick="preview();">
            <input type="button" value="word下载" class="xinzengbtn" onclick="downWord();">
            <input type="button" value="pdf下载" class="xinzengbtn" onclick="downPdf();">
          </div>
          <div>
            <input type="file" id="imgsInput" multiple>
            <table border="1" width="500px" style="border-collapse: collapse;" class="cankaoTable">
              <thead>
              <tr>
                <th width="70%">文件名</th>
                <th width="15%">操作</th>
                <th width="15%">预览</th>
              </tr>
              </thead>
              <tbody id="fileList">
              <!-- 这里将显示上传的文件名 -->
              </tbody>
            </table>

            <div id="previewContainer">
              <img class="previewImage" id="previewImage" src="" alt="预览图片">
              <button onclick="closePreview()">关闭预览</button>
            </div>
          </div>
          <table class="leftrighttable" border="0" cellpadding="5">
            <tr style="border:1px solid black">
              <td width="14%" class="tdname">医案编号</td>
              <td width="20%"><input disabled="disabled" type="text" id="biaohao" class="yianinput" maxlength="50"></td>

              <td width="14%" class="tdname">经验方系数 </td>
              <td width="20%"><input type="text" id="ExperienceCoefficient" class="yianinput" maxlength="50"></td>

            </tr>
            <tr>
              <td valign="top">封面</td>
              <td>
                <img src="/images/zhongyao.png" id="img4" alt="" class="zhongyaopic"> <br />
                <div class="fileUpload">
                  <span id="spSmallImage4">上传封面</span>
                  <input type="file" id="smallfile4" name="imageCover" class="upload" onchange="previewImageCover()" />
                  <input type="hidden" id="hidSmallPic4" value="" />
                </div>
              </td>

              <td valign="top">版权页</td>
              <td>
                <img src="/images/zhongyao.png" id="img5" alt="" class="zhongyaopic"> <br />
                <div class="fileUpload">
                  <span id="spSmallImage5">上传版权页</span>
                  <input type="file" id="smallfile5" name="imageRight" class="upload" onchange="previewImageRight()" />
                  <input type="hidden" id="hidSmallPic5" value="" />
                </div>
              </td>
            </tr>
            <tr>
              <td width="14%" class="tdname">患者姓名 </td>
              <td width="20%"><input type="text" id="xingming" class="yianinput"  maxlength="50">
              </td>
              <td width="12%" class="tdname">接诊医生 </td>
              <td width="14%"><input type="text" id="jiuzhenyisheng" class="yianinput"
                  maxlength="50"></td>
              <td width="13%" class="tdname" colspan="1">就诊 </td>
              <td width="20%" colspan="2">
                <select id="jiuzhenleixin" style="width:80px;float:left">
                  <option value="初诊">初诊</option>
                  <option value="复诊">复诊</option>
                </select>
                <select id="keshi" style="float:left; margin-right:16px;">
                  <option value="">请选择</option>
                  <option value="内科">内科</option>
                  <option value="外科">外科</option>
                  <option value="儿科">儿科</option>
                  <option value="妇科">妇科</option>
                  <option value="皮肤科">皮肤科</option>
                  <option value="五官科">五官科</option>
                  <option value="急诊">急诊</option>
                </select>
              </td>
            </tr>
            <tr>
              <td width="13%" class="tdname">性别 </td>
              <td width="20%">
                <select id="xingbie">
                  <option value="男" selected="selected">男</option>
                  <option value="女">女</option>
                </select>
                &nbsp; &nbsp;&nbsp; 婚况
                <select id="hunkuang">
                  <option value="">请选择</option>
                  <option value="已婚">已婚</option>
                  <option value="未婚">未婚</option>
                </select>
              </td>
              <td width="12%" class="tdname">药物过敏史 </td>
              <td width="14%"><input type="text" id="yaowoguominshi" class="yianinput" maxlength="50"></td>

              <td width="14%" class="tdname" colspan="1">
                就诊时间

              </td>
              <td width="20%" colspan="2">
                <input type="text" id="year" class="yianinput" style="width:30px;" >
                年
                <input type="text" id="month" class="yianinput" style="width:20px;" >
                月
                <input type="text" id="day" class="yianinput" style="width:20px;" >
                日
                其他
                <input type="text" id="otherTime" class="yianinput" style="width:35px;" >
              </td>
            </tr>
            <tr>
              <td width="13%" class="tdname">年龄 </td>
              <td width="20%"><input type="text" id="nianling" class="yianinput" maxlength="50"></td>
              <td width="12%" class="tdname">发病节气 </td>
              <td width="14%"><input type="text" id="fabingjieqi" class="yianinput" maxlength="50"></td>
              <td width="13%" class="tdname">朝代 </td>
              <td width="20%">
                <select id="chaodai" style="width:162px;height:28px;">
                  <option value="">请选择</option>
                  <option value="1979年后">1979年后</option>
                  <option value="1949-1979年">1949-1979年</option>
                  <option value="民国">民国</option>
                  <option value="清">清</option>
                  <option value="明">明</option>
                  <option value="元">元</option>
                  <option value="宋">宋</option>
                  <option value="隋唐五代">隋唐五代</option>
                  <option value="魏晋南北朝">魏晋南北朝</option>
                  <option value="汉">汉</option>
                  <option value="先秦">先秦</option>
                  <option value="上古">上古</option>
                </select>
              </td>
            </tr>
            <tr>
              <td width="13%" class="tdname">书名</td>
              <td width="20%">
                <input type="text" id="shuming" class="textinput_ai" onclick="searchData()" oninput="searchData()">
                <ul id="searchResults" class="searchResults" style="display: none"></ul>
              </td>
              <td width="12%" class="tdname">编者/主编 </td>
              <td width="14%"><input type="text" id="zuozhe" class="yianinput" maxlength="50"></td>
              <td width="13%" class="tdname">出版社 </td>
              <td width="20%"><input type="text" id="chubanshe" class="yianinput" maxlength="50"></td>
            </tr>
            <tr>
              <td width="13%" class="tdname">版次 </td>
              <td width="20%"><input type="text" id="banci" class="yianinput" maxlength="50"></td>
              <td width="12%" class="tdname">出版时间 </td>
              <td width="14%"><input type="text" id="chubanshijian" class="yianinput" maxlength="50"></td>

              <td width="13%" class="tdname" colspan="1">起始页</td>
              <td width="20%" colspan="2">

                <input type="text" id="yema" class="yianinput" style="width:45px;">
                &nbsp;&nbsp;终止页
                <input type="text" id="yemaEnd" class="yianinput" style="width:45px;">
              </td>
            </tr>
            <tr>
              <td width="13%" class="tdname">ISBN </td>
              <td width="20%"><input type="text" id="isbn" class="yianinput" maxlength="50"></td>

            </tr>
          </table>
          <table class="leftrighttable" border="0" cellpadding="5" id="divRecord" style="display: none;"></table>
          <div class="fengexian"><!-- fengexian -------------------------------------------------------></div>
          <table class="leftrighttable" border="0" cellpadding="5"><tr>
      <div class="core">
        <p style="text-align:center">
          全文内容录入
        </p>
        <div class="source">
          <img id="imgPreview" src="/images/OCR.png" alt="需要识别的图片">
          <label for="fileInput">上传图片</label>
          <input type="file" id="fileInput" accept="image/png,image/jpg,image/jpeg" onchange="ocrPreview()">
        </div>
        <div class="result">
          <textarea name="" id="resultMsg" cols="30" rows="10"></textarea>
          <button onclick="OCR()">图片识别</button>
          <button id="copyBtn" onclick="copyToClipboard()">复制全文</button>
        </div>
      </div>
    </tr>
          </table>
      <div class="fengexian"><!-- fengexian -------------------------------------------------------></div>
          <table class="leftrighttable" border="0" cellpadding="5">
            <tr>
              <td colspan="4"><span class="yianbiaoti">问</span></td>
            </tr>

            <tr>
              <td width="13%" class="tdname" valign="top">主诉</td>
              <td colspan="3">
                <textarea id="zhushu" class="textareainput" style="width: 800px;"></textarea>
              </td>
            </tr>
            <tr>
              <td width="13%" class="tdname" valign="top">现病史</td>
              <td colspan="3"><textarea id="xianbingshi" class="textareainput"
                  style="width: 800px;height:100px;"></textarea></td>
            </tr>
            <tr>
              <td width="12%" class="tdname">家族史 </td>
              <td colspan="3"><textarea id="jiazushi" class="textareainput"
                  style="width: 800px;height:100px;"></textarea></td>
            </tr>
            <tr>
              <td width="13%" class="tdname">既往史 </td>
              <td colspan="3"><textarea id="jiwangshi" class="textareainput"
                  style="width: 800px;height:100px;"></textarea></td>
            </tr>
          </table>

          <div class="fengexian"><!-- fengexian----------------------------------------------------- --></div>
          <table class="leftrighttable" border="0" cellpadding="5">
            <tr>
              <td colspan="5"><span class="yianbiaoti">
                  <p style="font-size:18px;">舌脉</p>
                </span></td>
            </tr>
            <tr>
              <td class="tdname" valign="top" align="right">
                <br />

                <p>舌脉总体情况</p><br /><br /><br />

                <p>具体舌脉</p><br /><br /><br /><br /><br />

              </td>

              <td colspan="4" style="border:1px solid green;">
                <table cellpadding="10">
                  <tr>
                    <td colspan="3" style="height: 32px; width: 300px;">
                      <textarea id="shezhen" class="textareainput" style="height: 26px; width: 270px; "></textarea>
                    </td>
                  </tr>
                  <tr>
                    <td id="shese">
                      舌色<br />
                      <label>
                        <input type="checkbox" name="shese" value="淡" />淡
                      </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="shese" value="绛" />绛
                      </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="shese" value="尖红" />尖红
                      </label>&nbsp;&nbsp;&nbsp;&nbsp;<br />
                      <label>
                        <input type="checkbox" name="shese" value="淡红" />淡红
                      </label>&nbsp;&nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="shese" value="暗" />暗
                      </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="shese" value="尖微红" />尖微红
                      </label>&nbsp;<br />
                      <label>
                        <input type="checkbox" name="shese" value="淡白" />淡白
                      </label>&nbsp;&nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="shese" value="暗红" />暗红
                      </label>&nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="shese" value="边尖红" />边尖红
                      </label>&nbsp;<br />
                      <label>
                        <input type="checkbox" name="shese" value="红" />红
                      </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="shese" value="紫" />紫
                      </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="shese" value="根微黄" />根微黄
                      </label>&nbsp;<br />
                      <label>
                        <input type="checkbox" name="shese" value="红绛" />红绛
                      </label>&nbsp;&nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="shese" value="淤点" />淤点
                      </label>&nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="shese" value="根微腻" />根微腻
                      </label>&nbsp;
                    </td>

                    <td id="shexing">
                      舌形<br />
                      <label>
                        <input type="checkbox" name="shexing" value="胖大" />胖大
                      </label><br />
                      <label>
                        <input type="checkbox" name="shexing" value="瘦薄" />瘦薄
                      </label><br />
                      <label>
                        <input type="checkbox" name="shexing" value="点刺" />点刺
                      </label><br />
                      <label>
                        <input type="checkbox" name="shexing" value="裂纹" />裂纹
                      </label><br />
                      <label>
                        <input type="checkbox" name="shexing" value="齿痕" />齿痕
                      </label><br />
                    </td>

                    <td id="shetai" style="border:1px ">
                      舌态<br />
                      <label>
                        <input type="checkbox" name="shetai" value="歪斜" />歪斜
                      </label><br />
                      <label>
                        <input type="checkbox" name="shetai" value="颤动" />颤动
                      </label><br />
                      <label>
                        <input type="checkbox" name="shetai" value="吐弄" />吐弄
                      </label><br />
                      <label>
                        <input type="checkbox" name="shetai" value="短缩" />短缩
                      </label><br />
                      <label>
                        <input type="checkbox" name="shetai" value="麻痹" />麻痹
                      </label><br />
                    </td>
                    <td id="taizhi">
                      苔质<br />
                      <label>
                        <input type="checkbox" name="taizhi" value="苔薄" />苔薄
                      </label><br />
                      <label>
                        <input type="checkbox" name="taizhi" value="苔厚" />苔厚
                      </label><br />
                      <label>
                        <input type="checkbox" name="taizhi" value="苔润" />苔润
                      </label>&nbsp;
                      <label>
                        <input type="checkbox" name="taizhi" value="苔燥" />苔燥
                      </label><br />
                      <label>
                        <input type="checkbox" name="taizhi" value="苔腻" />苔腻
                      </label>&nbsp;
                      <label>
                        <input type="checkbox" name="taizhi" value="苔腐" />苔腐
                      </label><br />
                      <label>
                        <input type="checkbox" name="taizhi" value="剥落" />剥落
                      </label>&nbsp;
                      <label>
                        <input type="checkbox" name="taizhi" value="水滑" />水滑
                      </label>
                    </td>

                    <td id="taise">
                      苔色<br />
                      <label>
                        <input type="checkbox" name="taise" value="白苔" />白苔
                      </label><br />
                      <label>
                        <input type="checkbox" name="taise" value="黄苔" />黄苔
                      </label><br />
                      <label>
                        <input type="checkbox" name="taise" value="灰苔" />灰苔
                      </label><br />
                      <label>
                        <input type="checkbox" name="taise" value="黑苔" />黑苔
                      </label><br />
                      <label>
                        <input type="checkbox" name="taise" value="黑苔" style="display:none" />
                      </label><br />
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
            <tr>
              <td class="tdname" valign="top" align="right" width="13%">
                <p>不常用舌苔</p>
              </td>
              <!--添加其他舌象-->
              <td>
                <div>
                  <input type="text" id="userInput" onkeypress="addEnter_2(event)">
                  <button onclick="addCustomOption()">添加不常用舌苔</button>
                  <button onclick="clearTable_2()">清空表格</button>
                </div>

              </td>
            </tr>
            <!--添加其他舌象生成区-->

            <tr>
              <td class="tdname" valign="top" align="right" width="13%">
                <p>舌苔生成区</p>
              </td>
              <td colspan="4">
                <table class="xiyijianchabiao" id="resultTable">
                  <tr bgcolor="#f2f2f2">
                    <th width="20%">序号</th>
                    <th width="30%">类型</th>
                    <th width="50%">值</th>
                  </tr>
                </table>
                </br>
              </td>
            </tr>
            <tr>
              <td class="tdname" valign="top" align="right" width="13%">
                <br />
                <p>具体脉象</p>
                <br /><br />
                <p></p>
              </td>
              <td colspan="4" style="border:1px solid green;">
                <table cellpadding="8">
                  <tr>
                    <td>
                      左右<br />
                      <label>
                        <input type="checkbox" name="fumai" value="左" onclick="updateSelection_M('左')" />左
                      </label> &nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="fumai" value="右" onclick="updateSelection_M('右')" />右
                      </label> &nbsp;&nbsp;&nbsp;
                    </td>

                    <td>
                      寸关尺<br />
                      <label>
                        <input type="checkbox" name="fumai" value="寸" onclick="updateSelection_M('寸')" />寸
                      </label> &nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="fumai" value="关" onclick="updateSelection_M('关')" />关
                      </label> &nbsp;&nbsp;&nbsp;
                      <label>
                        <input type="checkbox" name="fumai" value="尺" onclick="updateSelection_M('尺')" />尺
                      </label> &nbsp;&nbsp;&nbsp;
                    </td>
                  </tr>
                </table>
                <table cellpadding="8">
                  <tr>
                    <td>
                      浮脉类<br />
                      <label>
                        <input type="checkbox" name="fumai" value="浮" onclick="updateSelection_M('浮')" />浮
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="洪" onclick="updateSelection_M('洪')" />洪
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="濡" onclick="updateSelection_M('濡')" />濡
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="散" onclick="updateSelection_M('散')" />散
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="芤" onclick="updateSelection_M('芤')" />芤
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="革" onclick="updateSelection_M('革')" />革
                      </label><br />
                    </td>
                    <td>
                      沉脉类<br />
                      <label>
                        <input type="checkbox" name="fumai" value="沉" onclick="updateSelection_M('沉')" />沉
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="伏" onclick="updateSelection_M('伏')" />伏
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="牢" onclick="updateSelection_M('牢')" />牢
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="弱" onclick="updateSelection_M('弱')" />弱
                      </label><br />
                      <br />
                      <br />
                    </td>
                    <td>
                      数脉类<br />
                      <label>
                        <input type="checkbox" name="fumai" value="数" onclick="updateSelection_M('数')" />数
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="促" onclick="updateSelection_M('促')" />促
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="疾" onclick="updateSelection_M('疾')" />疾
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="动" onclick="updateSelection_M('动')" />动
                      </label><br />
                      <br />
                      <br />
                    </td>
                    <td>
                      迟脉类<br />
                      <label>
                        <input type="checkbox" name="fumai" value="迟" onclick="updateSelection_M('迟')" />迟
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="缓" onclick="updateSelection_M('缓')" />缓
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="涩" onclick="updateSelection_M('涩')" />涩
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="结" onclick="updateSelection_M('结')" />结
                      </label><br />
                      <br />
                      <br />
                    </td>
                    <td>
                      虚脉类<br />
                      <label>
                        <input type="checkbox" name="fumai" value="虚" onclick="updateSelection_M('虚')" />虚
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="微" onclick="updateSelection_M('微')" />微
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="细" onclick="updateSelection_M('细')" />细
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="代" onclick="updateSelection_M('代')" />代
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="短" onclick="updateSelection_M('短')" />短
                      </label><br />
                      <br />
                    </td>
                    <td>
                      实脉类<br />
                      <label>
                        <input type="checkbox" name="fumai" value="实" onclick="updateSelection_M('实')" />实
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="滑" onclick="updateSelection_M('滑')" />滑
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="紧" onclick="updateSelection_M('紧')" />紧
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="弦" onclick="updateSelection_M('弦')" />弦
                      </label><br />
                      <label>
                        <input type="checkbox" name="fumai" value="长" onclick="updateSelection_M('长')" />长
                      </label><br />
                      <br />
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
            <tr>
              <td class="tdname" valign="top" align="right" width="13%">
                <p>其他脉象</p>
              </td>
              <td>
                <div>
                  <input type="text" id="userInputText" placeholder="请输入内容">
                  <button onclick="addToTable_M()">添加</button>
                  <button onclick="clearTable_M()">清空表格</button>
                </div>
              </td>
            </tr>
            <tr>
              <td class="tdname" valign="top" align="right" width="13%">
                <p>脉象生成区</p>
              </td>
              <td colspan="4">
                <table class="xiyijianchabiao" id="resultTable_2">
                  <thead>
                  <tr bgcolor="#f2f2f2">
                    <th>序号</th>
                    <th>内容</th>
                  </tr>
                  </thead>
                  <tbody id="tableBody_M">
                  </tbody>
                </table>
              </td>
            </tr>

          </table>
          <div class="fengexian"><!-- fengexian --></div>


          <table width="950" class="leftrighttable" border="0" cellpadding="5" style="margin-left:20px;border:0px;">
            <tr>
              <td width="440" colspan="2"><span class="yianbiaoti">症候</span></td>
              <td width="510" colspan="2"><span class="yianbiaoti">&nbsp;</span></td>
            </tr>
            <tr>
              <td>
                <div class="dropdown">
                  <label for="select1">寒热</label><input type="text" id="select1" placeholder="请选择" readonly onclick="toggleDropdown('dropdown1')">
                  <div id="dropdown1" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select2">汗证</label><input type="text" id="select2" placeholder="请选择" readonly onclick="toggleDropdown('dropdown2')">
                  <div id="dropdown2" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select3">全身/形体</label><input type="text" id="select3" placeholder="请选择" readonly onclick="toggleDropdown('dropdown3')">
                  <div id="dropdown3" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select4">神志</label><input type="text" id="select4" placeholder="请选择" readonly onclick="toggleDropdown('dropdown4')">
                  <div id="dropdown4" class="dropdown-content"></div>
                </div>
              </td>
            </tr>
            <tr>
              <td>
                <div class="dropdown">
                  <label for="select5">饮食</label><input type="text" id="select5" placeholder="请选择" readonly onclick="toggleDropdown('dropdown5')">
                  <div id="dropdown5" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select6">饮水</label><input type="text" id="select6" placeholder="请选择" readonly onclick="toggleDropdown('dropdown6')">
                  <div id="dropdown6" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select7">小便</label><input type="text" id="select7" placeholder="请选择" readonly onclick="toggleDropdown('dropdown7')">
                  <div id="dropdown7" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select8">大便</label><input type="text" id="select8" placeholder="请选择" readonly onclick="toggleDropdown('dropdown8')">
                  <div id="dropdown8" class="dropdown-content"></div>
                </div>
              </td>
            </tr>
            <tr>
              <td>
                <div class="dropdown">
                  <label for="select9">睡眠</label><input type="text" id="select9" placeholder="请选择" readonly onclick="toggleDropdown('dropdown9')">
                  <div id="dropdown9" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select10">语音</label><input type="text" id="select10" placeholder="请选择" readonly onclick="toggleDropdown('dropdown10')">
                  <div id="dropdown10" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select11">头面</label><input type="text" id="select11" placeholder="请选择" readonly onclick="toggleDropdown('dropdown11')">
                  <div id="dropdown11" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select12">头部</label><input type="text" id="select12" placeholder="请选择" readonly onclick="toggleDropdown('dropdown12')">
                  <div id="dropdown12" class="dropdown-content"></div>
                </div>
              </td>
            </tr>
            <tr>
              <td>
                <div class="dropdown">
                  <label for="select13">耳目</label><input type="text" id="select13" placeholder="请选择" readonly onclick="toggleDropdown('dropdown13')">
                  <div id="dropdown13" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select14">口鼻咽</label><input type="text" id="select14" placeholder="请选择" readonly onclick="toggleDropdown('dropdown14')">
                  <div id="dropdown14" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select15">颈项</label><input type="text" id="select15" placeholder="请选择" readonly onclick="toggleDropdown('dropdown15')">
                  <div id="dropdown15" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select16">胸腹</label><input type="text" id="select16" placeholder="请选择" readonly onclick="toggleDropdown('dropdown16')">
                  <div id="dropdown16" class="dropdown-content"></div>
                </div>
              </td>
            </tr>
            <tr>
              <td>
                <div class="dropdown">
                  <label for="select17">腰背</label><input type="text" id="select17" placeholder="请选择" readonly onclick="toggleDropdown('dropdown17')">
                  <div id="dropdown17" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select18">四肢</label><input type="text" id="select18" placeholder="请选择" readonly onclick="toggleDropdown('dropdown18')">
                  <div id="dropdown18" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select19">月经</label><input type="text" id="select19" placeholder="请选择" readonly onclick="toggleDropdown('dropdown19')">
                  <div id="dropdown19" class="dropdown-content"></div>
                </div>
              </td>
              <td>
                <div class="dropdown">
                  <label for="select20">白带</label><input type="text" id="select20" placeholder="请选择" readonly onclick="toggleDropdown('dropdown20')">
                  <div id="dropdown20" class="dropdown-content"></div>
                </div>
              </td>
            </tr>
            <tr>

            <td width="405" colspan="3">
              <div style="margin-top: 1px; ">
                <div class="dropdown">
                  <label for="select21">搜索症候</label><input type="text" id="select21" placeholder="请选择" readonly onclick="toggleDropdown('dropdown21')">
                  <div id="dropdown21" class="dropdown-content"></div>
                </div>
              </div>
            </td>
      </tr>
      <tr>
        <td valign="top" align="right">
          手动症候
        </td>
        <td colspan="3">
          <input type="text" id="shoudongZhenghou" class="textinput_ai">
        </td>
      </tr>

    </table>

    <div class="fengexian"><!-- fengexian --></div>
          <table width="950" class="leftrighttable" border="0" cellpadding="5" style="margin-left:20px;border:0px;">
            <tr><th>中医诊断</th></tr>
    <tr>

      <td width="135" valign="top" align="right">
        <div style="margin-top:12px;">输入病名</div>
      </td>


      <td width="305">
        <input type="text" id="zyzd" class="textinput_ai">
        <div style="margin-top: 5px; ">

          <div class="dropdown">
            <label for="select22">搜索病机</label><input type="text" id="select22" placeholder="请选择" readonly onclick="toggleDropdown('dropdown22')" class="dropdownLabel">
            <div id="dropdown22" class="dropdown-content"></div>
          </div>
        </div>


      </td>
      <td width="85" valign="top">
        <div style="margin-top:12px;">&nbsp;</div>
      </td>
      <td width="425">
        &nbsp;
      </td>
    </tr>
          </table>
    <div class="fengexian"><!-- fengexian --></div>

    <table class="leftrighttable" border="0" cellpadding="5">
      <tr>
        <td><span class="yianbiaoti">西医检查数据</span> &nbsp; &nbsp;</td>
        <td ><span onclick="showNoXiyi()"
            style="color:#009933; cursor:pointer;">简&nbsp;版</span></td>
        <td><span onclick="showxiyibiao()" style="color:#009933; cursor:pointer;">详细版</span></td>

      </tr>
    </table>
          <table class="leftrighttable" border="0" cellpadding="5" id="jianShiyan">
            <tr>
              <td colspan="4"><span class="yianbiaoti">实验室检查</span></td>
            </tr>
            <tr>
              <td width="135" class="tdname" valign="top"></td>
              <td colspan="3"><textarea id="sysjc" class="textareainput" style="width: 600px;"></textarea></td>
            </tr>
          </table>
    <table id="xiyijianchabiao" class="leftrighttable" width="950" border="1" cellpadding="5" style="display:none;">
      <tr>
        <td width="130" align="right">检查项目</td>
        <td width="200">
          <select id="jianchaxiangmu" style="width:162px;border:1px solid #ddd;">
            <option value="">请选择</option>
            <option value="血常规">血常规</option>
            <option value="尿常规">尿常规</option>
            <option value="肝功能">肝功能</option>
            <option value="心电图">心电图</option>
            <option value="B超">B超</option>
            <option value="X片">X片</option>
          </select>
        </td>
        <td width="70" rowspan="4">
          <input type="button" value="增加项&gt;" class="tianjiabtn" onclick="addXiyiJc();">
        </td>
        <td width="550" rowspan="4" valign="top">
          <table class="xiyijianchabiao" id="divJiancha">
            <tr bgcolor="#f2f2f2">
              <th width="10%">序号</th>
              <th width="18%">检查项目</th>
              <th width="20%">检查时间</th>
              <th width="27%">结果摘要</th>
              <th width="10%">图片</th>
              <th>操作</th>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td align="right">检查时间</td>
        <td><input type="date" id="shijian" class="yianinput"></td>
      </tr>
      <tr>
        <td align="right">结果摘要</td>
        <td><input type="text" id="jieguo" class="yianinput"></td>
      </tr>
      <tr>
        <td align="right"></td>
        <td>
          <div class="fileUpload">
            <span id="spJianchaImage">上传检查图片</span>
            <input type="file" id="jianchafile" name="jianchafile" class="upload" />
            <input type="hidden" id="hidJianchaPic" value="" />
          </div>
        </td>
      </tr>
    </table>

    <div class="fengexian"><!-- fengexian --></div>

    <table width="950" class="leftrighttable" border="0" cellpadding="5" style="margin-left:20px;border:0px;">
      <tr>
        <td width="440" colspan="2"><span class="yianbiaoti">西医诊断</span></td>
        <td width="510" colspan="2"><span class="yianbiaoti">&nbsp;</span></td>
      </tr>
      <tr>

        <td width="135" valign="top" align="right">
          <div style="margin-top:12px;">输入病名</div>
        </td>
        <td width="305">
        <td valign="top">
          <input type="text" id="xiyiBingming" class="textinput_ai" onkeypress="addEnter(event)">
          <input type="button" value="添 加" onclick="addXyZhenduan();" class="tianjiabtn">
          <input type="button" value="清 空" onclick="clearXyZhenduanShow();" class="tianjiabtn">
          </div>
          <label class="showAdd" id="xyBmshowAdd"> </label>
        </td>
      </tr>
    </table>
    <div class="fengexian"><!-- fengexian --></div>

    <table width="950" class="leftrighttable" border="0" cellpadding="5" style="margin-left:20px;border:0px;">
      <tr>
        <td width="440" colspan="2"><span class="yianbiaoti">治则治法</span></td>
        <td width="510" colspan="2"><span class="yianbiaoti">&nbsp;</span></td>
      </tr>
      <tr>


        <td width="135" valign="top" align="right">
          <div style="margin-top:12px;"></div>
        </td>
        <td width="305">
          <table>
            <tr>
              <td width="40">治则 </td>
              <td>
                <select id="zhize" style="width:265px;border:1px solid #ddd;">
                  <option value="">请选择</option>
                  <option value="早治防变">早治防变</option>
                  <option value="治病求本">治病求本</option>
                  <option value="扶正祛邪">扶正祛邪</option>
                  <option value="急则治标">急则治标</option>
                  <option value="缓则治本">缓则治本</option>
                  <option value="正治">正治</option>
                  <option value="反治">反治</option>
                  <option value="调整阴阳">调整阴阳</option>
                  <option value="调理气血">调理气血</option>
                  <option value="调理脏腑">调理脏腑</option>
                  <option value="三因制宜">三因制宜</option>
                </select>
              </td>

            </tr>
            <tr>
              <td>治法 </td>
              <td>
                <select id="zhifa" style="width:265px;border:1px solid #ddd;">
                  <option value="">请选择</option>
                  <option value="汗">汗</option>
                  <option value="吐">吐</option>
                  <option value="下">下</option>
                  <option value="和">和</option>
                  <option value="温">温</option>
                  <option value="清">清</option>
                  <option value="补">补</option>
                  <option value="消">消</option>
                  <option value="涩">涩</option>
                </select>
              </td>
            </tr>
            <tr>
              <td valign="top">说明 </td>
              <td><textarea id="shuoming" class="textareainput"></textarea></td>
            </tr>
          </table>
        </td>
        <td width="85" valign="top">&nbsp;</td>
        <td width="425">&nbsp;</td>
      </tr>
    </table>

    <div class="fengexian"><!-- fengexian --></div>

    <table class="leftrighttable" border="0" cellpadding="5">
      <tr>
        <td><span class="yianbiaoti">医案处方</span> &nbsp; &nbsp; &nbsp;<a class="" style="cursor: pointer" onclick="showJianban()">简 版</a> &nbsp;
          &nbsp; &nbsp;<a class=""  style="cursor: pointer" onclick="showXiangban()">详细版</a></td>
      </tr>
    </table>
<!--     简单版本     -->
    <table id="jianban" class="leftrighttable" width="950" cellpadding="5">
      <tr>
        <td align="right">处方名称</td>
        <td><input type="text" id="jianCfmc" class="textinput"> </td>
      </tr>
      <tr>
        <td colspan="6">
          <hr style="border:1px solid #eeeeee; width:95%; float:right;">
        </td>
      </tr>
      <tr>
        <td width="130" align="right">中药名</td>
        <td>
<!--          显示中药-->
          <input type="text" id="jianYaoming" class="textinput" onclick="searchZhongyao()" oninput="searchZhongyao()">
          <ul id="zhongyaoSearchResults" class="searchResults" style="display: none"></ul>
          <div id='selectYM'
            style="width: 160px;display: none; border: 1px solid #ddd; position: relative;  z-index: 11; background: #fff; ">
          </div>
        </td>

        <td colspan="2">
          <table>
            <tr>
              <td class="tdname">药量 </td>
              <td><input type="text" id="yaoliang_jd" class="yianinput"></td>
            </tr>
          </table>
        </td>
        <td align="right">备注</td>
        <td><input type="text" id="beizhu_jd" class="yianinput">&nbsp;&nbsp;<input type="submit" value="增加药&gt;"
            onclick="addCf_J()" class="tianjiabtn"></td>
      </tr>
      <tr>
        <td width="130" align="right">总药味: <span id="spnumber_jd"></span></td>
        <td colspan="5">
<!--          <table class="xiyijianchabiao" id="zhongyaoShow_J">-->
<!--            <tr bgcolor="#f2f2f2">-->
<!--              <th width="13%">序号</th>-->
<!--              <th width="22%">中药名</th>-->
<!--              <th width="20%">药量</th>-->
<!--              <th width="20%">备注</td>-->
<!--              <th>操作</th>-->
<!--            </tr>-->
<!--          </table>-->
          <div class="tianjiafangjidiv" id="zhongyaoShow_J" style="width: 100%; border:4px solid">

          </div>
          <br>
          <br>
        </td>
      </tr>
      <tr>
        <td width="130" align="right">剂数</td>
        <td colspan="2">
          <input type="text" id="jishu_jb" class="yianinput">
        </td>
        <td width="130" align="right">煎服法</td>
        <td colspan="2">
          <input type="text" id="jianfufa_jb" class="yianinput">
        </td>
      </tr>
    </table>

    <!-- 详版 ------------------------------------------------------------------ -->
    <table id="xiangban" style="display: none;" class="leftrighttable" border="1" cellpadding="5">
      <tr>
        <td width="130" class="tdname">处方名称 </td>
        <td width="180"><input type="text" id="chufangmingcheng" class="yianinput"></td>
        <td width="130" class="tdname">类型 </td>
        <td width="180">
          <select id="leixing" style="width:162px;">
            <option value="自拟">自拟</option>
            <option value="成方化裁">成方化裁</option>
          </select>
        </td>
        <td width="120" class="tdname">剂型 </td>
        <td width="210">
          <select id="jixing" style="width:162px;">
            <option value="汤">汤</option>
            <option value="丸">丸</option>
            <option value="散">散</option>
            <option value="膏">膏</option>
            <option value="丹">丹</option>
            <option value="茶">茶</option>
            <option value="露">露</option>
            <option value="锭">锭</option>
            <option value="酒">酒</option>
            <option value="条">条</option>
            <option value="线">线</option>
            <option value="洗">洗</option>
            <option value="搽">搽</option>
            <option value="栓">栓</option>
          </select>
        </td>
      </tr>
      <tr>
        <td class="tdname">煎服法 </td>
        <td>
          <select id="jianfufa" style="width:162px;">
            <option value="">请选择</option>
            <option value="久煎">久煎</option>
            <option value="轻煎">轻煎</option>
            <option value="去渣再煎">去渣再煎</option>
            <option value="泡服">泡服</option>
          </select>
        </td>
        <td class="tdname">服药时间 </td>
        <td>
          <select id="fuyaoshijian" style="width:162px;">
            <option value="">请选择</option>
            <option value="饭前">饭前</option>
            <option value="饭后">饭后</option>
            <option value="早晨">早晨</option>
            <option value="中午">中午</option>
            <option value="晚上">晚上</option>
          </select>
        </td>
        <td class="tdname">剂数 </td>
        <td><input type="text" id="jishu" class="yianinput"></td>
      </tr>
      <tr>
        <td class="tdname">使用方法 </td>
        <td>
          <select id="shiyongfangfa" style="width:162px;">
            <option value="">请选择</option>
            <option value="内用">内用</option>
            <option value="外用">外用</option>
            <option value="熏蒸">熏蒸</option>
            <option value="坐浴">坐浴</option>
          </select>
        </td>
        <td class="tdname">次数和药量 </td>
        <td>
          <input type="text" id="cishuyaoliang" class="yianinput">
        </td>
        <td class="tdname"> </td>
        <td> </td>
      </tr>
      <tr>
        <td class="tdname">服后反馈 </td>
        <td>
          <select id="fuhoufankui" style="width:162px;">
            <option value="">请选择</option>
            <option value="痊愈">痊愈</option>
            <option value="好转">好转</option>
            <option value="不详">不详</option>
          </select>
        </td>
        <td class="tdname">其他事项 </td>
        <td>
          <input type="text" id="qitashixiang" class="yianinput">
        </td>
        <td class="tdname"> </td>
        <td> </td>
      </tr>

      <tr>
        <td colspan="6">
          <hr style="border:1px solid #eeeeee; width:95%; float:right;">
          <table width="900" border="0" cellpadding="5">

            <tr>
              <td width="110" align="right"> 中药名</td>
              <td>
                <input type="text" id="zhongyaoming" class="textinput" onclick="searchZhongyao_X()" oninput="searchZhongyao_X()">
                <ul id="zhongyaoSearchResults_X" class="searchResults" style="display: none"></ul>
                <div id='selectZYM'
                  style="width: 160px;display: none; border: 1px solid #ddd; position: relative; z-index: 11; background: #fff; ">

                </div>
              </td>

              <td width="80" rowspan="6"><input type="button" value="增加药&gt;" class="tianjiabtn" onclick="addCf_X()"></td>
              <td width="30" rowspan="6" valign="top">
                &nbsp; 总药味:  <span id="spnumber_X"></span></td>
              <td width="500" rowspan="6">
<!--                <table class="xiyijianchabiao" id="zhongyaoShow_X">-->
<!--                  <tr bgcolor="#f2f2f2">-->
<!--                    <th width="8%">序号</th>-->
<!--                    <th width="15%">中药名</th>-->
<!--                    <th width="10%">药量</th>-->
<!--                    <th width="10%">待定</th>-->
<!--                    <th width="10%">炮制</th>-->
<!--                    <th width="10">产地</th>-->
<!--                    <th width="10">备注</th>-->
<!--                    <th>操作</th>-->
<!--                  </tr>-->
<!--                </table>-->
                <div class="tianjiafangjidiv" id="zhongyaoShow_X" style="width: 100%; border:4px solid">

                </div>
              </td>
            </tr>

            <tr>
              <td align="right">药量</td>
              <td><input type="text" id="yaoliang" class="yianinput"></td>
            </tr>
            <tr>
              <td align="right"></td>
              <td>
                <input type="radio" id="jinzhi" name="jinguzhi" value="今制" checked="checked">今制 <input type="radio"
                  id="guzhi" name="jinguzhi" value="古制">古制
                <select id="daiding">
                  <option value="待定">待定</option>
                  <option value="君">君</option>
                  <option value="臣">臣</option>
                  <option value="配">配</option>
                  <option value="佐">佐</option>
                  <option value="伍">伍</option>
                </select>
              </td>
            </tr>
            <tr>
              <td align="right">炮制</td>
              <td><input type="text" id="paozhi" class="yianinput"></td>
            </tr>
            <tr>
              <td align="right">产地</td>
              <td><input type="text" id="chandi" class="yianinput"></td>
            </tr>
            <tr>
              <td align="right">备注</td>
              <td>
                <select id="beizhu" style="width:162px;">
                  <option value="">请选择</option>
                  <option value="先煎">先煎</option>
                  <option value="后下">后下</option>
                  <option value="另煎">另煎</option>
                  <option value="包煎">包煎</option>
                </select>
              </td>
            </tr>
          </table>

        </td>
      </tr>
    </table>

    <div class="fengexian"><!-- fengexian --></div>

    <table class="leftrighttable" border="0" cellpadding="5">
      <tr>
        <td colspan="4"><span class="yianbiaoti">其他医嘱</span></td>
      </tr>
      <tr>
        <td width="135" class="tdname" valign="top"></td>
        <td colspan="3"><textarea id="qtyz" class="textareainput" style="width: 600px;"></textarea></td>
      </tr>
    </table>


    <div class="fengexian"><!-- fengexian --></div>

    <table class="leftrighttable" border="0" cellpadding="5">
      <tr>
        <td colspan="4"><span class="yianbiaoti">药后反馈</span></td>
      </tr>
      <tr>
        <td width="135" class="tdname" valign="top"></td>
        <td colspan="3"><textarea id="bafx" class="textareainput" style="width: 600px;"></textarea></td>
      </tr>
    </table>

    <div class="fengexian"><!-- fengexian --></div>

    <table class="leftrighttable" border="0" cellpadding="5">
      <tr>
        <td colspan="4"><span class="yianbiaoti">病案评论及要点</span></td>
      </tr>
      <tr>
        <td width="135" class="tdname" valign="top"></td>
        <td colspan="3"><textarea id="xxxd" class="textareainput" style="width: 600px;"></textarea></td>
      </tr>
    </table>
    <div class="fengexian"><!-- fengexian --></div>
    <table class="leftrighttable" border="0" cellpadding="5" style="display:none" id="starTable">
      <tr>
        <td><span id="pingfen" class="yianbiaoti"></span></td>
        <td>
          <div class="starts">
            <ul id="pingStar">
              <li rel="1" title="1分">★</li>
              <li rel="2" title="2分">★</li>
              <li rel="3" title="3分">★</li>
              <li rel="4" title="4分">★</li>
              <li rel="5" title="5分">★</li>
              <li><span id="dir"></span></li>
            </ul>
            <input type="hidden" value="" id="startP">
          </div>
        </td>
      </tr>
    </table>
    <div class="fengexian"><!-- fengexian --></div>
    <div class="shenhediv">
      <input type="button" value="保&nbsp;&nbsp;存" id="saveButton" class="baocunbtn"
        onclick="saveBtn();">
      <input type="button" value="保存并添加复诊"  id="saveButtonAndMore" class="baocunbtn"
             onclick="saveAndMore();">
      <br><br>
      <input type="button" value="提&nbsp;&nbsp;交" id="submitButton" class="baocunbtn"
             onclick="submitBtn();">
      <input type="button" value="提交并添加复诊"  id="submitButtonAndMore" class="baocunbtn"
             onclick="submitAndMore();">
    </div>
    </td>
    </tr>
    </table>
  </form>

</body>

</html>
<script>
  const langPath = '/tesseract.js-offline-master/lang-data'; // 指向包含中文语言包的目录
  let worker = null;  //OCR相关
  var sheData = [];
  var maiData = [];
  var jianchaData = [];
  var yaoData = [];
  var bookData;
  var zhenghouData,optionsZhenghou;
  var zhongyiZhengzhuangData,optionsZhongyi;
  var zhongyaoData;
  var shenhe = '保存';
  var cankao = [];
  var bookName = document.getElementById('shuming');
  var bookAuthor = document.getElementById('zuozhe');
  var bookPublisher = document.getElementById('chubanshe');
  var bookEdition = document.getElementById('banci');
  var bookEditionTime = document.getElementById('chubanshijian');
  var bookISBN = document.getElementById('isbn');
  var xiyiXiangmu = document.getElementById('jianchaxiangmu');
  var xiyiShijian = document.getElementById('shijian');
  var xiyiJieguo = document.getElementById('jieguo');
  var xiyiTupian = document.getElementById('jianchafile');
  var xiyiJcShow = document.getElementById('divJiancha');
  var xiyiBingming = document.getElementById('xiyiBingming');
  var xyBmshowAdd = document.getElementById('xyBmshowAdd');
  var jianban = document.getElementById('jianban');
  var xiangban = document.getElementById('xiangban');
  var chufangming_J = document.getElementById('jianCfmc');
  var zhongyaoming_J = document.getElementById('jianYaoming');
  var yaoliang_J = document.getElementById('yaoliang_jd');
  var beizhu_J = document.getElementById('beizhu_jd');
  var zongyaowei_J = document.getElementById('chufangdivjiandan');
  var jishu_J = document.getElementById('jishu_jb');
  var jianfufa_J = document.getElementById('jianfufa_jb');
  var zhongyaoShow_J = document.getElementById('zhongyaoShow_J');
  var chufangming_X = document.getElementById('chufangmingcheng');
  var leixing_X = document.getElementById('leixing');
  var jixing_X = document.getElementById('jixing');
  var jianfufa_X = document.getElementById('jianfufa');
  var fuyaoshijian_X = document.getElementById('fuyaoshijian');
  var jishu_X = document.getElementById('jishu');
  var shiyongfangfa_X =document.getElementById('shiyongfangfa');
  var cishuyaoliang_X = document.getElementById('cishuyaoliang');
  var fuhoufankui_X = document.getElementById('fuhoufankui');
  var qitashixiang_X =document.getElementById('qitashixiang');
  var zhongyaoming_X =document.getElementById('zhongyaoming');
  var yaoliang_X = document.getElementById('yaoliang');
  var jinguzhiJin_X = document.getElementById('jinzhi');
  var jinguzhiGu_X = document.getElementById('guzhi');
  var daiding_X =document.getElementById('daiding');
  var paozhi_X = document.getElementById('paozhi');
  var chandi_X =document.getElementById('chandi');
  var beizhu_X = document.getElementById('beizhu');
  var zhongyaoShow_X = document.getElementById('zhongyaoShow_X');
  var nian = document.getElementById('year');
  var yue = document.getElementById('month');
  var ri = document.getElementById('day');
  var otherTime = document.getElementById('otherTime');
  var yianBianhao = document.getElementById('biaohao');
  var jingyanfangXishu = document.getElementById('ExperienceCoefficient');
  var fengmian = document.getElementById('smallfile4');
  var banquanye = document.getElementById('smallfile5');
  var huanzheXingming = document.getElementById('xingming');
  var jiezhenYisheng = document.getElementById('jiuzhenyisheng');
  var chufuzhen = document.getElementById('jiuzhenleixin');
  var keshi = document.getElementById('keshi');
  var xingbie = document.getElementById('xingbie');
  var hunkuang = document.getElementById('hunkuang');
  var yaowuguominshi = document.getElementById('yaowoguominshi');
  var nianling = document.getElementById('nianling');
  var fabingJieqi = document.getElementById('fabingjieqi');
  var chaodai = document.getElementById('chaodai');
  var qishiye = document.getElementById('yema');
  var zhongzhiye = document.getElementById('yemaEnd');
  var zhusu = document.getElementById('zhushu');
  var xianbingshi = document.getElementById('xianbingshi');
  var jiazushi = document.getElementById('jiazushi');
  var jiwangshi = document.getElementById('jiwangshi');
  var shemaiZongtiqingkuang = document.getElementById('shezhen');
  //舌再定  脉再定  td
  var shiyanshiJiancha = document.getElementById('sysjc');
  //20条再定 done
  var hanre = document.getElementById('select1');
  var hanzheng = document.getElementById('select2');
  var xingti = document.getElementById('select3');
  var shenzhi =document.getElementById('select4');
  var yinshi =document.getElementById('select5');
  var yinshui =document.getElementById('select6');
  var xiaobian =document.getElementById('select7');
  var dabian = document.getElementById('select8');
  var shuimian =document.getElementById('select9');
  var yuyin = document.getElementById('select10');
  var toumian =document.getElementById('select11');
  var toubu = document.getElementById('select12');
  var ermu = document.getElementById('select13');
  var koubiyan =document.getElementById('select14');
  var jingxiang = document.getElementById('select15');
  var xiongfu = document.getElementById('select16');
  var  yaobei = document.getElementById('select17');
  var sizhi = document.getElementById('select18');
  var yuejing = document.getElementById('select19');
  var baidai = document.getElementById('select20');
  var zhenghou = document.getElementById('select21');
  var bingji = document.getElementById('select22');
  var inputZhenghou = document.getElementById('shoudongZhenghou');
  var inputBingji = document.getElementById('zyzd');
  //症候再定  病机再定 zd  西医检查数据再定 zd
  var xiyiZhenduan = document.getElementById('xyBmshowAdd');
  var zhize = document.getElementById('zhize');
  var zhifa = document.getElementById('zhifa');
  var shuoming = document.getElementById('shuoming');
  var qitaYizhu = document.getElementById('qtyz');
  var yaohoufankui = document.getElementById('bafx');
  var yaodian = document.getElementById('xxxd');
  var jcTupian = [];
  getData('/book/',1);
  getData('/wxya/zhenghou',2);
  getData('/wxya/zhongyiZhengzhuang',3);
  getData('/zyxx/',4);
  //OCR识别函数，异步
  async function OCR() {
    var ocrImg = document.getElementById('fileInput').files[0];
    var ocrShow = document.getElementById('resultMsg');
    var imagePreView = document.getElementById('imgPreview');
    if (!ocrImg) {
      alert('请选择要识别的图片！');
      return;
    }
    var imgUrl = window.URL.createObjectURL(ocrImg);
    imagePreView.setAttribute("src", imgUrl);
    // 更改img url 以后释放 url
    imagePreView.onload = function () {
      console.log('图片加载成功');
      URL.revokeObjectURL(imgUrl)//安全性，释放URL
    };
    alert("正在识别！请稍等！");
    // 先终止和清理之前的Worker
    await terminateWorker();

    // 初始化新的Worker
    await initWorker();
    try {
      const result = await worker.recognize(ocrImg);
      ocrShow.textContent = result.data.text;
    } catch (err) {
      console.error('OCR失败：', err);
      alert('图片文字识别失败！请检查图片大小格式等！');
    }

  }
  //OCR相关，初始化函数
  async function initWorker() {
    worker = Tesseract.createWorker({ langPath });
    await worker.load();
    await worker.loadLanguage('eng+chi_sim');
    // 英文是 eng    中英混合是  eng+chi_sim   中文是   chi_sim
    await worker.initialize('eng+chi_sim');
  }
  // OCR相关，终止和清理Worker
  async function terminateWorker() {
    if (worker) {
      await worker.terminate();
      worker = null;
    }
  }
  //复制到剪切板函数
  async function copyToClipboard() {
    const textToCopy = document.getElementById('resultMsg').value;
    console.log(textToCopy);
    try {
      await navigator.clipboard.writeText(textToCopy);
    } catch (err) {
      console.error('复制到剪贴板失败：', err);
      alert('复制到剪贴板失败，请手动复制文本：' + textToCopy);
    }
  }
  function previewImageCover() {
    var preview = document.getElementById('img4');
    var fileDom = document.getElementById('smallfile4');
    // 获取得到file 对象
    var file = fileDom.files[0]
    // 限制上传图片的大小
    if (file.size > 1024 * 1024 * 5) {
      alert('图片大小不能超过 5MB!');
      return false;
    }
    // 创建url
    var imgUrl = window.URL.createObjectURL(file)
    preview.setAttribute("src", imgUrl)
    // 更改img url 以后释放 url
    preview.onload = function () {
      console.log('图片1加载成功')
      URL.revokeObjectURL(imgUrl)//安全性，释放URL
    }
  }
  function previewImageRight() {
    var preview = document.getElementById('img5');
    var fileDom = document.getElementById('smallfile5');
    // 获取得到file 对象
    var file = fileDom.files[0]
    // 限制上传图片的大小
    if (file.size > 1024 * 1024 * 5) {
      alert('图片大小不能超过 5MB!');
      return false;
    }
    // 创建url
    var imgUrl = window.URL.createObjectURL(file)
    preview.setAttribute("src", imgUrl)
    // 更改img url 以后释放 url
    preview.onload = function () {
      console.log('图片2加载成功')
      URL.revokeObjectURL(imgUrl)//安全性，释放URL
    }
  }
  function getData(url,somedata) {
    fetch(url)
      .then(response => response.json())
      .then(data => {
        data.forEach(obj => {
          for (let key in obj) {
            if (obj.hasOwnProperty(key) && obj[key] === null) {
              obj[key] = ''; // 将属性值为 null 的属性替换为空字符串
            }
          }
        });
        switch (somedata){
          case 1:bookData = data;
                 break;
          case 2:zhenghouData = data;
            optionsZhenghou = zhenghouData.map(item => item.zhenghou);
                  break;
          case 3:zhongyiZhengzhuangData = data;
             optionsZhongyi = zhongyiZhengzhuangData.map(item => item.mingcheng);
             initialize();
            break;
          case 4:
            zhongyaoData=data;
            break;
        }
      //  console.log(data);
       // somedata = data; // 将返回的数据赋值给全局变量
      })
      .catch(error => {
        console.error('Error fetching data:', error);
      });
  }
  function searchData() {
    var keyword = bookName.value.trim().toUpperCase();
    var results = document.getElementById('searchResults');
    // 清空之前的查询结果
    results.style.display = 'block';
    results.innerHTML = '';
    // 遍历JSON数据，查找匹配的信息
    for (var i = 0; i < bookData.length; i++) {
      var book = bookData[i];
      var nameIndex = book.name;
      if (nameIndex == null)
        continue;
      var name = nameIndex.toUpperCase();
      if (name.includes(keyword)) {
        // 创建li元素，并将匹配的信息添加到ul标签中
        var li = document.createElement('li');
        li.textContent = nameIndex;
        // 添加自定义属性保存对应的bookData对象
        li.bookData = book;
        // 添加click事件监听器
        li.addEventListener('click', function () {
          var nothing = '';
          // 点击查询结果时，将信息装配到input标签中
          bookName.value = this.bookData.name;
          bookAuthor.value = this.bookData.author;
          bookPublisher.value = this.bookData.publisher;
          bookEdition.value = this.bookData.edition;
          bookEditionTime.value = this.bookData.editionTime;
          bookISBN.value = this.bookData.isbn;
          // 将查询结果隐藏
          results.style.display = 'none';
        });
        results.appendChild(li);
      }
    }
    document.addEventListener('click', function (event) {
      const targetElement = event.target;

      // 检查点击事件的目标元素是否位于searchResults或其子元素内，以及是否位于输入框内
      const clickedInsideSearchResults = targetElement === results || results.contains(targetElement);
      const clickedInsideSearchInput = targetElement === bookName;

      // 如果不是点击在searchResults或输入框内，隐藏searchResults
      if (!clickedInsideSearchResults && !clickedInsideSearchInput) {
        results.style.display = 'none';
      }
    });
  }
  function searchZhongyao() {
    var keyword = zhongyaoming_J.value.trim().toUpperCase();
    var results = document.getElementById('zhongyaoSearchResults');
    // 清空之前的查询结果
    results.style.display = 'block';
    results.innerHTML = '';
    // 遍历JSON数据，查找匹配的信息
    for (var i = 0; i < zhongyaoData.length; i++) {
      var zhongyao = zhongyaoData[i];
      var nameIndex = zhongyao.yaoming;
      if (nameIndex == null)
        continue;
      var name = nameIndex.toUpperCase();
      if (name.includes(keyword)) {
        // 创建li元素，并将匹配的信息添加到ul标签中
        var li = document.createElement('li');
        li.textContent = nameIndex;
        // 添加自定义属性保存对应的bookData对象
        li.zhongyaoData = zhongyao;
        // 添加click事件监听器
        li.addEventListener('click', function () {
          // 点击查询结果时，将信息装配到input标签中
          zhongyaoming_J.value = this.zhongyaoData.yaoming;
          // 将查询结果隐藏
          results.style.display = 'none';
        });
        results.appendChild(li);
      }
    }
    document.addEventListener('click', function (event) {
      const targetElement = event.target;

      // 检查点击事件的目标元素是否位于searchResults或其子元素内，以及是否位于输入框内
      const clickedInsideSearchResults = targetElement === results || results.contains(targetElement);
      const clickedInsideSearchInput = targetElement === zhongyaoming_J;

      // 如果不是点击在searchResults或输入框内，隐藏searchResults
      if (!clickedInsideSearchResults && !clickedInsideSearchInput) {
        results.style.display = 'none';
      }
    });
  }
  function searchZhongyao_X() {
    var keyword = zhongyaoming_X.value.trim().toUpperCase();
    var results = document.getElementById('zhongyaoSearchResults_X');
    // 清空之前的查询结果
    results.style.display = 'block';
    results.innerHTML = '';
    // 遍历JSON数据，查找匹配的信息
    for (var i = 0; i < zhongyaoData.length; i++) {
      var zhongyao = zhongyaoData[i];
      var nameIndex = zhongyao.yaoming;
      if (nameIndex == null)
        continue;
      var name = nameIndex.toUpperCase();
      if (name.includes(keyword)) {
        // 创建li元素，并将匹配的信息添加到ul标签中
        var li = document.createElement('li');
        li.textContent = nameIndex;
        // 添加自定义属性保存对应的bookData对象
        li.zhongyaoData = zhongyao;
        // 添加click事件监听器
        li.addEventListener('click', function () {
          // 点击查询结果时，将信息装配到input标签中
          zhongyaoming_X.value = this.zhongyaoData.yaoming;
          // 将查询结果隐藏
          results.style.display = 'none';
        });
        results.appendChild(li);
      }
    }
    document.addEventListener('click', function (event) {
      const targetElement = event.target;

      // 检查点击事件的目标元素是否位于searchResults或其子元素内，以及是否位于输入框内
      const clickedInsideSearchResults = targetElement === results || results.contains(targetElement);
      const clickedInsideSearchInput = targetElement === zhongyaoming_X;

      // 如果不是点击在searchResults或输入框内，隐藏searchResults
      if (!clickedInsideSearchResults && !clickedInsideSearchInput) {
        results.style.display = 'none';
      }
    });
  }
  function ocrPreview(){
    var ocrImg = document.getElementById('fileInput').files[0];
    var imagePreView = document.getElementById('imgPreview');
    if (!ocrImg) {
      return;
    }
    var imgUrl = window.URL.createObjectURL(ocrImg);
    imagePreView.setAttribute("src", imgUrl);
    // 更改img url 以后释放 url
    imagePreView.onload = function () {
      URL.revokeObjectURL(imgUrl)//安全性，释放URL
    };
  }
  function showxiyibiao(){
    document.getElementById('xiyijianchabiao').style.display='block';
    document.getElementById('jianShiyan').style.display='none';
  }
  function showNoXiyi(){
    document.getElementById('xiyijianchabiao').style.display='none';
    document.getElementById('jianShiyan').style.display='block';
  }
  //添加西医检查数据的表格
  function addXiyiJc(){
    let xiangmu = xiyiXiangmu.value;
    if(xiangmu==""){
      alert("请选择检查项目！");
      return;
    }
    let shijian = xiyiShijian.value;
    let jieguo = xiyiJieguo.value;
    let tupian = xiyiTupian.files[0];
    const newRow = xiyiJcShow.insertRow();
    // 创建并填充每个单元格
    const cell1 = newRow.insertCell();
    cell1.textContent = (xiyiJcShow.rows.length - 1).toString();
    const cell2 = newRow.insertCell();
    cell2.textContent = xiangmu;
    const cell3 = newRow.insertCell();
    cell3.textContent = shijian;
    const cell4 = newRow.insertCell();
    cell4.classList.add('xiyiCell');
    cell4.textContent = jieguo;
    const cell5 = newRow.insertCell();
    cell5.classList.add('xiyiCell');
    if(tupian!=null)
      cell5.textContent = tupian.name;
    const cell6 = newRow.insertCell();
    var deleteLink = document.createElement("a");
    deleteLink.href = "#";
    deleteLink.textContent = "删除";
    deleteLink.onclick = function () {
      deleteRow(this);
    };
    cell6.appendChild(deleteLink);
    jcTupian.push(tupian !== null ? tupian : null);
    xiyiXiangmu.value="请选择";
      xiyiShijian.value='';
      xiyiJieguo.value='';
      xiyiTupian.value='';

  }
  // 西医检查数据表格的删除函数
  function deleteRow(link) {
    var row = link.parentNode.parentNode;
    event.preventDefault(); // 阻止默认链接点击行为
    row.parentNode.removeChild(row);
  }
  //西医诊断的检测回车添加数据
  function addEnter(event){
    // 检查按下的按键是否为回车键，回车键的keyCode是13
    if (event.keyCode === 13) {
      addXyZhenduan();
    }
  }
  //西医诊断添加内容
  function addXyZhenduan(){
    var value = xiyiBingming.value+",";
    if(value==",")
      return;
    xiyiBingming.value="";
    xyBmshowAdd.innerText=xyBmshowAdd.innerText + value;
  }
  //清空上面的内容
  function clearXyZhenduanShow(){
    xyBmshowAdd.innerText="";
  }
  function showJianban(){
    jianban.style.display='block';
    xiangban.style.display='none';
  }
  function showXiangban(){
    jianban.style.display='none';
    xiangban.style.display='block';
  }
  let cnt_J=0,cnt_X=0;
  var data_J=[],data_X=[];
  var spnumber_jd = document.getElementById('spnumber_jd');
  var spnumber_X = document.getElementById('spnumber_X');
  function addCf_J(){
    let zhongyao = zhongyaoming_J.value;
    if(zhongyao==""){
      alert("请输入中药名！");
      return;
    }
    let yaoliang = yaoliang_J.value;
    let beizhu = beizhu_J.value;
    zhongyaoming_J.value='';
    yaoliang_J.value='';
    beizhu_J.value='';
    if (!isNaN(yaoliang)&&yaoliang!='') {
      yaoliang = yaoliang + "克";
    }
    var exist = false;
    if (!exist) {
      var sort = 0;
      if (data_J.length > 0) {
        sort = data_J[data_J.length - 1].sort+1;
      }
      data_J[cnt_J]={
        zhongyao:zhongyao,
        yaoliang:yaoliang,
        beizhu:beizhu,
        paozhi:null,
        chandi:null,
        daiding:null,
        sort:sort
      }
    }
    cnt_J++;
    addCf_J_Show();
  }
  addCf_J_Show();
  function addCf_J_Show(){
    var container = document.getElementById('zhongyaoShow_J');
    if (data_J.length!=0) {
      var html = "";
      for(var j=0;j<data_J.length;j++){
        for(var k=0;k+1<data_J.length-j;k++){
          if(data_J[k].sort>data_J[k+1].sort){
            var t=data_J[k];
            data_J[k]=data_J[k+1];
            data_J[k+1]=t;
          }
        }
      }
      for (var i = 0; i < data_J.length; i++) {
        var item = data_J[i];
        html += '<span class="fangjispan">' + item.zhongyao + ' &nbsp; ' + item.yaoliang + ' &nbsp; ' + item.beizhu + ' &nbsp; ' + ' <img src="/images/quxiao.png" alt="" class="quxiaopic" onclick="del_J(\'' +i + '\')">';
        if (i != 0) {
          html += '<img src="/images/up.png" class="quxiaopic" onclick="up_J(\'' + i + '\')"><img>';
        }
        if (i != data_J.length-1) {
          html += '<img src="/images/down.png" class="quxiaopic" onclick="down_J(\'' + i + '\')"><img>';
        }
        html += '</span>';
      }
      spnumber_jd.innerHTML = data_J.length;
      // 清空容器
      container.innerHTML = "";
      // 添加新内容
      container.innerHTML += html;
    } else {
      spnumber_jd.innerHTML = 0;
      container.innerHTML = "";
    }
  }
  function del_J(p) {
    data_J.splice(p,1)
    cnt_J--;
    addCf_J_Show();
  }
  function up_J(i) {
    var sortp=data_J[i].sort
    data_J[i].sort=data_J[i-1].sort
    data_J[i-1].sort=sortp
    addCf_J_Show();
  }
  function down_J(i) {
    var sortp=data_J[i].sort
    data_J[i].sort=data_J[++i].sort
    data_J[i].sort=sortp
    addCf_J_Show();
  }
  function addCf_X(){
    let zhongyao = zhongyaoming_X.value;
    if(zhongyao==""){
      alert("请输入中药名");
      return;
    }
    let yaoliang = yaoliang_X.value;
    let paozhi = paozhi_X.value;
    let chandi = chandi_X.value;
    let beizhu = beizhu_X.value;
    let daiding = daiding_X.value;
    zhongyaoming_X.value='';
    yaoliang_X.value='';
    paozhi_X.value='';
    chandi_X.value='';
    beizhu_X.value='';
    daiding_X.value='待定';
    if (!isNaN(yaoliang)&&yaoliang!='') {
      yaoliang = yaoliang + "克";
    }
    var exist = false;

    if (!exist) {
      var sort = 0;
      if (data_X.length > 0) {
        sort = data_X[data_X.length - 1].sort+1;
      }
      data_X[cnt_X]={
        zhongyao:zhongyao,
        yaoliang:yaoliang,
        daiding:daiding,
        paozhi:paozhi,
        chandi:chandi,
        beizhu:beizhu,
        sort:sort
      }
    }
    cnt_X++;
    addCf_X_Show();
  }
  function addCf_X_Show(){
    var container = document.getElementById('zhongyaoShow_X');
    if (data_X.length!=0) {
      var html = "";
      for(var j=0;j<data_X.length;j++){
        for(var k=0;k+1<data_X.length-j;k++){
          if(data_X[k].sort>data_X[k+1].sort){
            var t=data_X[k];
            data_X[k]=data_X[k+1];
            data_X[k+1]=t;
          }
        }
      }
      for (var i = 0; i < data_X.length; i++) {
        var item = data_X[i];
        html += '<span class="fangjispan">' + item.zhongyao + ' &nbsp; ' + item.yaoliang + ' &nbsp; ' + item.daiding + ' &nbsp; '+ item.paozhi + ' &nbsp; '+ item.chandi + ' &nbsp; '+ item.beizhu + ' &nbsp; ' + ' <img src="/images/quxiao.png" alt="" class="quxiaopic" onclick="del_X(\'' +i + '\')">';
        if (i != 0) {
          html += '<img src="/images/up.png" class="quxiaopic" onclick="up_X(\'' + i + '\')"><img>';
        }
        if (i != data_X.length-1) {
          html += '<img src="/images/down.png" class="quxiaopic" onclick="down_X(\'' + i + '\')"><img>';
        }
        html += '</span>';
      }
      spnumber_X.innerHTML = data_X.length;
      // 清空容器
      container.innerHTML = "";
      // 添加新内容
      container.innerHTML += html;
    } else {
      spnumber_X.innerHTML = 0;
      container.innerHTML = "";
    }
  }
  function del_X(p) {
    data_X.splice(p,1)
    cnt_X--;
    addCf_X_Show();
  }
  function up_X(i) {
    var sortp=data_X[i].sort
    data_X[i].sort=data_X[i-1].sort
    data_X[i-1].sort=sortp
    addCf_X_Show();
  }
  function down_X(i) {
    var sortp=data_X[i].sort
    data_X[i].sort=data_X[++i].sort
    data_X[i].sort=sortp
    addCf_X_Show();
  }
  function saveBtn(){
    postData();
    alert("保存成功！");
    jianchaData=[];
    jcTupian=[];
    window.location.href="/wxya";
  }
  function saveAndMore(){
    // 把上述内容的value都设置为空
    chufangming_J.value = '';
    zhongyaoming_J.value = '';
    yaoliang_J.value = '';
    beizhu_J.value = '';
    jishu_J.value = '';
    jianfufa_J.value = '';
    chufangming_X.value = '';
    leixing_X.value = '自拟';
    jixing_X.value = '汤';
    jianfufa_X.value = '';
    fuyaoshijian_X.value = '';
    jishu_X.value = '';
    shiyongfangfa_X.value = '';
    cishuyaoliang_X.value = '';
    fuhoufankui_X.value = '';
    qitashixiang_X.value = '';
    zhongyaoming_X.value = '';
    yaoliang_X.value = '';
    jinguzhiJin_X.checked=true;
    daiding_X.value = '待定';
    paozhi_X.value = '';
    chandi_X.value = '';
    beizhu_X.value = '';
    nian.value='';
    yue.value='';
    ri.value='';
    otherTime='';
    chufuzhen='复诊';
    zhongyaoShow_J.innerHTML="";
    zhongyaoShow_X.innerHTML="";
    showJianban();
    postData();
    alert("保存成功！");
    jianchaData=[];
    jcTupian=[];
  }
  function submitBtn(){
    shenhe= "提交";
    postData();
    alert("提交成功！");
    jianchaData=[];
    jcTupian=[];
    window.location.href="/wxya";
  }
  function submitAndMore(){
    shenhe="提交";
    // 把上述内容的value都设置为空
    chufangming_J.value = '';
    zhongyaoming_J.value = '';
    yaoliang_J.value = '';
    beizhu_J.value = '';
    jishu_J.value = '';
    jianfufa_J.value = '';
    chufangming_X.value = '';
    leixing_X.value = '自拟';
    jixing_X.value = '汤';
    jianfufa_X.value = '';
    fuyaoshijian_X.value = '';
    jishu_X.value = '';
    shiyongfangfa_X.value = '';
    cishuyaoliang_X.value = '';
    fuhoufankui_X.value = '';
    qitashixiang_X.value = '';
    zhongyaoming_X.value = '';
    yaoliang_X.value = '';
    jinguzhiJin_X.checked=true;
    daiding_X.value = '待定';
    paozhi_X.value = '';
    chandi_X.value = '';
    beizhu_X.value = '';
    nian.value='';
    yue.value='';
    ri.value='';
    otherTime='';
    chufuzhen='复诊';
    zhongyaoShow_J.innerHTML="";
    zhongyaoShow_X.innerHTML="";
    showJianban();
    postData();
    alert("提交成功！");
    jianchaData=[];
    jcTupian=[];
  }
  <!--下面的script是关于那22个框-->
  // 示例数据：多个数组，每个数组对应一个下拉多选框的选项
  var options1 = ['不恶寒', '不发热', '潮热', '但热不寒', '低热', '恶风', '恶风寒', '恶寒', '恶寒发热', '恶热', '发热', '高热', '寒栗', '寒热往来',
    '寒战', '内热', '怕风', '怕冷', '日晡潮热', '啬啬恶寒', '身寒', '身热', '身热不扬', '身热夜甚', '身热肢寒', '手足寒', '外寒', '往来寒热', '微恶风',
    '微恶风寒', '微热', '畏寒', '畏寒发热', '畏冷', '五心烦热', '午后潮热', '淅淅恶风', '翕翕发热', '夜热早凉', '一阵恶寒，一阵发热', '一阵怕冷，一阵发热', '憎寒发热',
    '战栗', '振寒', '蒸蒸发热', '壮热'];

  var options2 = ['多汗', '少汗', '半身汗出', '大汗', '但头汗出', '盗汗', '局部无汗', '局部有汗', '冷汗', '冷汗淋漓',
    '热甚汗多', '无汗','壮热无汗', '自汗', '微汗', '漐漐汗出', '汗出濈濈然'];

  var options3 = ['抽搐', '拘挛', '蠕动', '颤动', '肥胖', '消瘦', '肌肉疼痛', '肌肉发胀', '肌肉酸楚', '肌肉萎缩',
    '肉松皮缓', '乏力', '倦怠', '倦怠乏力', '四肢不用', '肢体瘫痪', '半身不遂', '蜷卧缩足', '仰面伸足', '坐而仰首',
    '坐而俯首', '麻木', '发麻', '疼痛', '皮肤干燥', '皮肤黄染', '浮肿', '易感冒', '瘙痒', '项软', '龟背', '项背拘急',
    '桶状胸', '鸡胸', '四肢疼痛'];

  var options4 = ['少神', '失神', '假神', '神乱', '神昏', '谵语', '有神', '急躁易怒', '多怒', '易怒', '喜怒',
    '心烦', '烦躁', '发狂', '喜静懒动', '善恐', '易惊', '闷闷不乐', '多疑善虑', '多愁善感', '抑郁', '多疑', '悲观',
    '喜叹气', '喜太息', '神情淡漠', '健忘', '喜忘', '呵欠', '见水欲尿'];

  var options5 = ['食欲不振', '纳食佳', '纳佳', '纳食尚可', '纳可', '纳食一般', '食少', '不欲食', '纳差', '纳呆',
    '纳少', '吞咽困难', '呃逆', '嗳气', '泛酸', '返酸', '反酸', '嘈杂', '烧心', '消谷善饥', '多食', '嗳气酸馊',
    '嗳腐吞酸', '多食易饥', '消谷善饥', '饥不欲食', '偏食', '偏嗜异物'];

  var options6 = ['口干', '口渴', '喜饮', '多饮', '不喜饮', '喜冷饮', '渴喜冷饮', '喜热饮', '渴喜热饮', '不渴',
    '口渴多饮', '口渴引饮', '口大渴', '口微渴', '渴不多饮'];

  var options7 = ['小便淡黄', '小便黄赤', '尿长', '尿短', '尿少', '尿短黄', '小便不利', '小便失禁', '小便自利',
    '尿后余沥', '尿不尽', '小便淋漓', '尿急', '尿频', '尿痛', '小便灼热', '尿清', '小便浑浊', '尿血',
    '尿中砂石', '尿浮脂膏', '小便泡沫', '小便臊臭', '小便味甜', '小便清长', '尿清长', '多尿', '小便不通',
    '夜尿多', '夜尿频多'];

  var options8 = ['大便尚可', '大便稀溏', '便滽', '大便溏', '大便偏稀', '大便干结', '便干', '大便干', '大便偏干',
    '溏结不调', '大便时干时稀', '经常便秘', '经常腹泻', '大便次数少', '大便次数多', '大便艰难', '大便不爽',
    '大便不畅', '大便失禁', '里急', '后重', '里急后重', '大便夹冻', '大便黏液', '便血', '大便带血', '黑便',
    '大便带虫', '大便味臭', '大便色绿', '大便色白', '大便量多', '大便量少', '大便细', '矢气', '放屁', '矢气多', '矢气少'];

  var options9 = ['不寐', '嗜睡', '多梦', '恶梦', '梦交', '睡眠尚可', '眠可', '梦游', '失眠', '多梦',
    '入睡困难', '睡后易醒', '易惊醒', '遗精'];

  var options10 = ['语言謇涩', '错语', '失语', '呓语', '声音高亢', '声音清脆', '声音嘶哑', '声音重浊', '语声低微', '谵语', '郑声'];

  var options11 = ['头痛', '头蒙', '头胀', '头重', '头昏', '头摇', '头身酸重', '牙齿松动', '牙痛', '牙龈肿', '牙龈出血',
    '目赤', '目晴发黄', '目眩', '目昏', '目干涩', '目痛', '目痒', '雀目', '近视', '暴盲', '两目灼热', '羞明流泪', '眵多',
    '眼窝凹陷', '眼球突出', '目瞤', '眼眶发黑', '眼睑下垂', '眼睑浮肿', '口苦', '口甜', '口酸', '口中酸馊', '口淡无味', '口眼歪斜',
    '口噤', '口臭', '多涎唾', '口角流涎', '唇麻', '唇热', '唇干', '唇肿', '鼻塞', '鼻痛', '鼻痒', '流涕', '鼻干', '鼻出血',
    '喷嚏', '鼻鼾', '不闻香臭', '咽干', '咽痛', '咽痒', '喉中痰鸣', '咽如物梗', '咽红', '咽肿', '咽喉溃烂', '耳鸣', '耳胀', '耳痛',
    '耳痒', '耳聋', '重听', '耳出血'];

  var options12 = ['头痛', '头蒙', '头胀', '头重', '头昏', '头摇', '头身酸重', '方头'];

  var options13 = ['目赤', '目晴发黄', '目眩', '目昏', '目干涩', '目痛', '目痒', '雀目', '近视', '暴盲', '两目灼热',
    '羞明流泪', '眵多', '眼窝凹陷', '眼球突出', '目瞤', '眼眶发黑', '眼睑下垂', '眼睑浮肿', '耳鸣', '耳胀',
    '耳痛', '耳痒', '耳聋', '重听', '耳出血'];

  var options14 = ['牙齿松动', '牙痛', '牙龈肿', '牙龈出血', '口苦', '口甜', '口酸', '口中酸馊', '口淡无味',
    '口眼歪斜', '口噤', '口臭', '多涎唾', '口角流涎', '唇麻', '唇热', '唇干', '唇肿', '鼻塞', '鼻痛',
    '鼻痒', '流涕', '鼻干', '鼻出血', '喷嚏', '鼻鼾', '不闻香臭', '咽干', '咽痛', '咽痒', '喉中痰鸣',
    '咽如物梗', '咽红', '咽肿', '咽喉溃烂'];

  var options15 = ['颈脉动甚', '瘰疬', '项软', '颈项拘急', '项背强', '头项强痛'];

  var options16 = ['恶心', '呕吐', '呕', '吐', '干呕', '哕', '咳嗽', '干咳', '呛咳', '顿咳', '呼吸急促',
    '呼吸困难', '呼吸气粗', '呼吸微弱', '气短', '上气', '少气/气微', '夺气', '胁痛', '胁胀', '胁部拘急',
    '胁部灼热', '腹痛', '腹胀', '单腹胀大', '肠鸣', '腹坠', '腹部板硬', '腹中灼热', '腹中发凉', '腹部悸动',
    '胸痛', '胸闷', '胸中灼热', '胸中发凉', '心悸', '心烦', '心悬', '乳房痛', '乳房胀', '乳头出血'];

  var options17 = ['腰痛', '背痛', '腰酸', '腰胀', '腰重', '腰冷', '腰热', '龟背', '项背拘急'];

  var options18 = ['足跟痛', '甲床淡白', '甲床青紫', '指甲干枯', '指甲反凹', '指甲薄软', '小腿青筋',
    '四肢不用', '痿废不用', '肢体瘫痪', '半身不遂', '偏瘫', '下肢水肿', '下肢微肿', '下肢浮肿',
    '四肢疼痛', '半身汗出', '四肢发凉', '肢冷', '下肢冷', '下肢发凉'];

  var options19 = ['月经量多', '月经量少', '月经时多时少', '月经先期', '月经后期', '月经先后无定期',
    '闭经', '经期缩短', '经期延长', '月经紫黯', '月经淡红', '月经鲜红',
    '月经血块', '痛经', '崩漏', '停经', '经行不畅', '月经质稀', '月经质稠', '经断复来', '经来骤止',
    '月经腥臭', '经间期出血'];
  var options20 = ['带下量多', '带下量少', '带下色白', '带下色黄', '带下色赤', '带下色青', '带下色黑',
    '带见五色', '带下味臭', '带下稀', '带下稠', '带下清', '带下浊', '阴痒'];
  // 创建下拉多选框的函数
  function createMultiSelect(options, dropdownId) {
    var dropdownContent = document.getElementById(dropdownId);

    // 清空之前的选项
    dropdownContent.innerHTML = '';

    // 创建选项并添加到下拉框
    options.forEach(function (option) {
      var label = document.createElement('label');
      var checkbox = document.createElement('input');
      checkbox.type = 'checkbox';
      checkbox.value = option;
      checkbox.onclick = function () {
        toggleOption(option, dropdownId);
      };
      label.appendChild(checkbox);
      label.appendChild(document.createTextNode(option));
      dropdownContent.appendChild(label);
    });
  }

  // 切换选项的状态（选中/取消选中）
  function toggleOption(option, dropdownId) {
    var selectInput = document.getElementById('select' + dropdownId.substr(8));
    var selectedOptions = selectInput.value.trim().split(',').map(function (item) {
      return item.trim();
    });

    var index = selectedOptions.indexOf(option);
    if (index === -1) {
      selectedOptions.push(option);
    } else {
      selectedOptions.splice(index, 1);
    }
    if(selectedOptions[0]==""){
      selectedOptions.shift();
    }
    selectInput.value = selectedOptions.join(', ');
  }

  // 切换下拉多选框的显示/隐藏
  function toggleDropdown(dropdownId) {
    var dropdownContent = document.getElementById(dropdownId);
    dropdownContent.classList.toggle('show');
  }

  // 初始化多个下拉多选框
  function initialize() {
    createMultiSelect(options1, 'dropdown1');
    createMultiSelect(options2, 'dropdown2');
    createMultiSelect(options3, 'dropdown3');
    createMultiSelect(options4, 'dropdown4');
    createMultiSelect(options5, 'dropdown5');
    createMultiSelect(options6, 'dropdown6');
    createMultiSelect(options7, 'dropdown7');
    createMultiSelect(options8, 'dropdown8');
    createMultiSelect(options9, 'dropdown9');
    createMultiSelect(options10, 'dropdown10');
    createMultiSelect(options11, 'dropdown11');
    createMultiSelect(options12, 'dropdown12');
    createMultiSelect(options13, 'dropdown13');
    createMultiSelect(options14, 'dropdown14');
    createMultiSelect(options15, 'dropdown15');
    createMultiSelect(options16, 'dropdown16');
    createMultiSelect(options17, 'dropdown17');
    createMultiSelect(options18, 'dropdown18');
    createMultiSelect(options19, 'dropdown19');
    createMultiSelect(options20, 'dropdown20');
    createMultiSelect(optionsZhenghou, 'dropdown21');
    createMultiSelect(optionsZhongyi, 'dropdown22');

    // 点击页面其他地方，关闭下拉多选框
    document.addEventListener('click', function (event) {
      var dropdowns = document.getElementsByClassName('dropdown-content');
      for (var i = 0; i < dropdowns.length; i++) {
        if (!event.target.closest('.dropdown')) {
          dropdowns[i].classList.remove('show');
        }
      }
    });
  }
  //initialize();
// /22个框代码截止处

  // 得到现在的时间，16位，用于biaohao
  function getCurrentDateTimeString() {
    const now = new Date();

    const year = now.getFullYear().toString().padStart(4, '0');
    const month = (now.getMonth() + 1).toString().padStart(2, '0');
    const day = now.getDate().toString().padStart(2, '0');
    const hours = now.getHours().toString().padStart(2, '0');
    const minutes = now.getMinutes().toString().padStart(2, '0');
    const milliseconds = now.getMilliseconds().toString().padStart(4, '0');

    const dateTimeString = year + month + day + hours + minutes + milliseconds;
    return dateTimeString;
  }
  function postData(){
    var jingyanfangxishuVal = jingyanfangXishu.value;
    if(jingyanfangxishuVal=='') {
      jingyanfangxishuVal = null;
    }
    var huanzheXingmingVal = huanzheXingming.value;
    if(huanzheXingmingVal==''){
      huanzheXingmingVal = null;
    }
    var jiezhenYishengVal = jiezhenYisheng.value;
    if(jiezhenYishengVal==''){
      jiezhenYishengVal = null;
    }
    var chufuzhenVal = chufuzhen.value;
    if(chufuzhenVal==''){
      chufuzhenVal = null;
    }
    var keshiVal = keshi.value;
    if(keshiVal==''){
      keshiVal = null;
    }
    var xingbieVal = xingbie.value;
    if(xingbieVal==''){
      xingbieVal = null;
    }
    var hunkuangVal = hunkuang.value;
    if(hunkuangVal==''){
      hunkuangVal = '';
    }
    var shemaiZongtiqingkuangVal = shemaiZongtiqingkuang.value;
    if(shemaiZongtiqingkuangVal==''){
      shemaiZongtiqingkuangVal=null;
    }
    var yaowuguominshiVal = yaowuguominshi.value;
    if(yaowuguominshiVal==''){
      yaowuguominshiVal=null;
    }
    var nianVal = nian.value;
    if(nianVal==''){
      nianVal = null;
    }
    var yueVal = yue.value;
    if(yueVal==''){
      yueVal = null;
    }
    var riVal = ri.value;
    if(riVal==''){
      riVal= null;
    }
    var otherTimeVal = otherTime.value;
    if(otherTimeVal==''){
      otherTimeVal=null;
    }
    var nianlingVal = nianling.value;
    if(nianlingVal=''){
      nianlingVal=null;
    }
    var fabingjieqiVal = fabingJieqi.value;
    if(fabingjieqiVal==''){
      fabingjieqiVal=null;
    }
    var chaodaiVal = chaodai.value;
    if(chaodaiVal==''){
      chaodaiVal=null;
    }
    var bookNameVal = bookName.value;
    if (bookNameVal == '') {
      bookNameVal = null;
    }
    var bookAuthorVal = bookAuthor.value;
    if (bookAuthorVal == '') {
      bookAuthorVal = null;
    }
    var bookPublisherVal = bookPublisher.value;
    if (bookPublisherVal == '') {
      bookPublisherVal = null;
    }
    var bookEditionVal = bookEdition.value;
    if (bookEditionVal == '') {
      bookEditionVal = null;
    }
    var bookEditionTimeVal = bookEditionTime.value;
    if (bookEditionTimeVal == '') {
      bookEditionTimeVal = null;
    }
    var bookISBNVal = bookISBN.value;
    if (bookISBNVal == '') {
      bookISBNVal = null;
    }
    var qishiyeVal = qishiye.value;
    if(qishiyeVal==''){
      qishiyeVal = null;
    }
    var zhongzhiyeVal = zhongzhiye.value;
    if(zhongzhiyeVal==''){
      zhongzhiyeVal = null;
    }
    var zhusuVal = zhusu.value;
    if (zhusuVal == '') {
      zhusuVal = null;
    }
    var xianbingshiVal = xianbingshi.value;
    if (xianbingshiVal == '') {
      xianbingshiVal = null;
    }
    var jiazushiVal = jiazushi.value;
    if (jiazushiVal == '') {
      jiazushiVal = null;
    }
    var jiwangshiVal = jiwangshi.value;
    if (jiwangshiVal == '') {
      jiwangshiVal = null;
    }
    var hanreVal = hanre.value;
    if (hanreVal === '') {
      hanreVal = null;
    }
    var hanzhengVal = hanzheng.value;
    if (hanzhengVal === '') {
      hanzhengVal = null;
    }
    var xingtiVal = xingti.value;
    if (xingtiVal === '') {
      xingtiVal = null;
    }
    var shenzhiVal = shenzhi.value;
    if (shenzhiVal === '') {
      shenzhiVal = null;
    }
    var yinshiVal = yinshi.value;
    if (yinshiVal === '') {
      yinshiVal = null;
    }
    var yinshuiVal = yinshui.value;
    if (yinshuiVal === '') {
      yinshuiVal = null;
    }
    var xiaobianVal = xiaobian.value;
    if (xiaobianVal === '') {
      xiaobianVal = null;
    }
    var dabianVal = dabian.value;
    if (dabianVal === '') {
      dabianVal = null;
    }
    var shuimianVal = shuimian.value;
    if (shuimianVal === '') {
      shuimianVal = null;
    }
    var yuyinVal = yuyin.value;
    if (yuyinVal === '') {
      yuyinVal = null;
    }
    var toumianVal = toumian.value;
    if (toumianVal === '') {
      toumianVal = null;
    }
    var toubuVal = toubu.value;
    if (toubuVal === '') {
      toubuVal = null;
    }
    var ermuVal = ermu.value;
    if (ermuVal === '') {
      ermuVal = null;
    }
    var koubiyanVal = koubiyan.value;
    if (koubiyanVal === '') {
      koubiyanVal = null;
    }
    var jingxiangVal = jingxiang.value;
    if (jingxiangVal === '') {
      jingxiangVal = null;
    }
    var xiongfuVal = xiongfu.value;
    if (xiongfuVal === '') {
      xiongfuVal = null;
    }
    var yaobeiVal = yaobei.value;
    if (yaobeiVal === '') {
      yaobeiVal = null;
    }
    var sizhiVal = sizhi.value;
    if (sizhiVal === '') {
      sizhiVal = null;
    }
    var yuejingVal = yuejing.value;
    if (yuejingVal === '') {
      yuejingVal = null;
    }
    var baidaiVal = baidai.value;
    if (baidaiVal === '') {
      baidaiVal = null;
    }
    var zhenghouVal = zhenghou.value;
    if (zhenghouVal === '') {
      zhenghouVal = null;
    }
    var bingjiVal = bingji.value;
    if (bingjiVal === '') {
      bingjiVal = null;
    }
    var inputZhenghouVal = inputZhenghou.value;
    if (inputZhenghouVal === '') {
      inputZhenghouVal = null;
    }
    var inputBingjiVal = inputBingji.value;
    if (inputBingjiVal === '') {
      inputBingjiVal = null;
    }
    var shiyanshijianchaVal = shiyanshiJiancha.value;
    if(shiyanshijianchaVal == ''||document.getElementById('jianShiyan').style.display=='block'){
      shiyanshijianchaVal =null;
    }
    var xiyiZhenduanVal = xiyiZhenduan.textContent;
    if (xiyiZhenduanVal === '') {
      xiyiZhenduanVal = null;
    }
    var zhizeVal = zhize.value;
    if (zhizeVal === '') {
      zhizeVal = null;
    }
    var zhifaVal = zhifa.value;
    if (zhifaVal === '') {
      zhifaVal = null;
    }
    var shuomingVal = shuoming.value;
    if (shuomingVal === '') {
      shuomingVal = null;
    }
    var qitaYizhuVal = qitaYizhu.value;
    if (qitaYizhuVal === '') {
      qitaYizhuVal = null;
    }
    var yaohoufankuiVal = yaohoufankui.value;
    if (yaohoufankuiVal === '') {
      yaohoufankuiVal = null;
    }
    var yaodianVal = yaodian.value;
    if (yaodianVal === '') {
      yaodianVal = null;
    }
    var chufangming_JVal = chufangming_J.value;
    if (chufangming_JVal === '') {
      chufangming_JVal = null;
    }
    var jishu_JVal = jishu_J.value;
    if (jishu_JVal === '') {
      jishu_JVal = null;
    }
    var jianfufa_JVal = jianfufa_J.value;
    if (jianfufa_JVal === '') {
      jianfufa_JVal = null;
    }
    var chufangming_XVal = chufangming_X.value;
    if (chufangming_XVal === '') {
      chufangming_XVal = null;
    }
    var leixing_XVal = leixing_X.value;
    if (leixing_XVal === ''||xiangban.style.display=='none') {
      leixing_XVal = null;
    }
    var jixing_XVal = jixing_X.value;
    if (jixing_XVal === ''||xiangban.style.display=='none') {
      jixing_XVal = null;
    }
    var jianfufa_XVal = jianfufa_X.value;
    if (jianfufa_XVal === '') {
      jianfufa_XVal = null;
    }
    var fuyaoshijian_XVal = fuyaoshijian_X.value;
    if (fuyaoshijian_XVal === ''||xiangban.style.display=='none') {
      fuyaoshijian_XVal = null;
    }
    var jishu_XVal = jishu_X.value;
    if (jishu_XVal === '') {
      jishu_XVal = null;
    }
    var shiyongfangfa_XVal = shiyongfangfa_X.value;
    if (shiyongfangfa_XVal === ''||xiangban.style.display=='none') {
      shiyongfangfa_XVal = null;
    }
    var cishuyaoliang_XVal = cishuyaoliang_X.value;
    if (cishuyaoliang_XVal === ''||xiangban.style.display=='none') {
      cishuyaoliang_XVal = null;
    }
    var fuhoufankui_XVal = fuhoufankui_X.value;
    if (fuhoufankui_XVal === ''||xiangban.style.display=='none') {
      fuhoufankui_XVal = null;
    }
    var qitashixiang_XVal = qitashixiang_X.value;
    if (qitashixiang_XVal === ''||xiangban.style.display=='none') {
      qitashixiang_XVal = null;
    }
    var jinguzhiVal;
    if (xiangban.style.display=='none') {
      jinguzhiVal = null;
    }
    else if(jinguzhiJin_X.checked){
      jinguzhiVal = '今';
    }
    else {
      jinguzhiVal = '古';
    }
    var daiding_XVal = daiding_X.value;
    if (daiding_XVal === ''||xiangban.style.display=='none') {
      daiding_XVal = null;
    }
    var chufangming,jishu,jianfufa;
    if(xiangban.style.display=='none'){
      chufangming = chufangming_JVal;
      jishu = jishu_JVal;
      jianfufa = jianfufa_JVal;
    }
    else {
      chufangming = chufangming_XVal;
      jishu = jishu_XVal;
      jianfufa = jianfufa_XVal;
    }
    // 创建要发送的数据对象，不包括文件
    var yianData = {
      biaohao: getCurrentDateTimeString(),
      xingming: huanzheXingmingVal,
      jiuzhenyisheng: jiezhenYishengVal,
      jiuzhenleixin: chufuzhenVal,
      keshi: keshiVal,
      xingbie: xingbieVal,
      hunkuang: hunkuangVal,
      yaowoguominshi: yaowuguominshiVal,
      year: nianVal,
      month: yueVal,
      day: riVal,
      otherTime: otherTimeVal,
      nianling: nianlingVal,
      fabingjieqi: fabingjieqiVal,
      chaodai: chaodaiVal,
      shuming: bookNameVal,
      yema: qishiyeVal,
      yemaEnd: zhongzhiyeVal,
      banci: bookEditionVal,
      chubanshijian: bookEditionTimeVal,
      zuozhe: bookAuthorVal,
      chubanshe: bookPublisherVal,
      zhushu: zhusuVal,
      xianbingshi: xianbingshiVal,
      shezhen: shemaiZongtiqingkuangVal,
      jzs: jiazushiVal,
      jws: jiwangshiVal,
      hanre: hanreVal,
      hanzhen: hanzhengVal,
      xingti: xingtiVal,
      shenzhi: shenzhiVal,
      yinshi: yinshiVal,
      yinshui: yinshuiVal,
      xiaobian: xiaobianVal,
      dabian: dabianVal,
      shuimian: shuimianVal,
      yuyan: yuyinVal,
      toumian: toumianVal,
      toubu: toubuVal,
      ermu: ermuVal,
      koubiyan: koubiyanVal,
      jingxiang: jingxiangVal,
      xiongfu: xiongfuVal,
      yaobei: yaobeiVal,
      sizhi: sizhiVal,
      shenhe: shenhe,
      yuejing: yuejingVal,
      baidai: baidaiVal,
      sysjc: shiyanshijianchaVal,
      zhize: zhizeVal,
      zhifa: zhifaVal,
      shuoming: shuomingVal,
      qtyz: qitaYizhuVal,
      bafx: yaohoufankuiVal,
      xxxd: yaodianVal,
      chufangmingcheng: chufangming,
      leixing: leixing_XVal,
      jixing: jixing_XVal,
      jianfufa: jianfufa,
      fuyaoshijian: fuyaoshijian_XVal,
      jishu: jishu,
      shiyongfangfa: shiyongfangfa_XVal,
      cishuyaoliang: cishuyaoliang_XVal,
      fuhoufankui: fuhoufankui_XVal,
      qitashixiang: qitashixiang_XVal,
      jinguzhi: jinguzhiVal
    };
    she();
    mai();
    if(document.getElementById('xiyijianchabiao').style.display=='block') {
      jiancha();
      shiyanshijianchaVal=null;
    }
    else{
      jianchaData=null;
      jcTupian=null;
    }

    var formData =new FormData();
    formData.append('yian',JSON.stringify(yianData));  //医案
    formData.append('she',JSON.stringify(sheData));  //舌
    formData.append('mai',JSON.stringify(maiData));  //脉
    formData.append('zhenghou',inputZhenghouVal+','+zhenghouVal);  //症状或症候
    formData.append('bingji',inputBingjiVal+','+bingjiVal);   //中医
    formData.append('zhenduan',xiyiZhenduanVal);   //西医诊断

    formData.append('jiancha',JSON.stringify(jianchaData));   //西医检查数据详细
    if(jcTupian==null){
      formData.append('fileArray', null);  //西医检查
    }
    else {
      for (var i = 0; i < jcTupian.length; i++) {
        if(jcTupian[i]==null){
          formData.append('fileArray', new Blob());  //空对象占位
        }
        else {
          formData.append('fileArray', jcTupian[i]);  //西医检查
        }
      }
    }
    if(jianban.style.display!='none'){
      formData.append('yao',JSON.stringify(data_J));  //处方
    }
    else {
      formData.append('yao',JSON.stringify(data_X));  //处方
    }
    formData.append('imageCover',fengmian.files[0]);
    formData.append('imageRight',banquanye.files[0]);
    for (var k = 0; k < cankao.length; k++) {
      formData.append('cankaoFiles', cankao[k]);  //参考图片
    }
    // 发送 POST 请求
    fetch('/wxya/', {
      method: 'POST',
      body: formData
    })
            .then(response => response.json())
            .then(data => {
              console.log("发送成功");
            })
            .catch(error => {
              console.log(error);
            });
  }
  function she() {
    // 获取表格元素
    var table = document.getElementById('resultTable');
    // 获取所有的<tr>元素
    var rows = table.querySelectorAll('tr');
    // 从第二行开始遍历每个<tr>元素，获取第二列和第三列的值
    for (var i = 1; i < rows.length; i++) {
      var row = rows[i];
      var columns = row.querySelectorAll('td');
      var typeValue = columns[1].textContent;
      var valueValue = columns[2].textContent;
      // 创建一个包含typeValue和valueValue的对象
      var dataObject = {
        type: typeValue,
        value: valueValue
      };
      // 将对象添加到dataArray数组中
      sheData.push(dataObject);
    }

  }
  function mai() {
    // 获取表格元素
    var table = document.getElementById('resultTable_2');
    // 获取表格的所有行
    var rows = table.getElementsByTagName('tr');
    // 从第一行开始遍历每一行，获取第二列的值
    for (var i = 1; i < rows.length; i++) {
      var row = rows[i];
      var columns = row.getElementsByTagName('td');
      var contentValue = columns[1].textContent;
      // 将contentValue添加到数组中
      maiData.push(contentValue);
    }
  }
  function jiancha() {
    // 获取表格元素
    var table = document.getElementById('divJiancha');
    var rows = table.getElementsByTagName('tr');

    for (var i = 1; i < rows.length; i++) {
      var row = rows[i];
      var columns = row.getElementsByTagName('td');
      // 获取第二列、第三列、第四列的值
      var column2Value = columns[1].textContent;
      var column3Value = columns[2].textContent;
      var column4Value = columns[3].textContent;
      if(column3Value==''){
        column3Value=null;
      }
      if(column4Value==''){
        column4Value=null;
      }
      // 创建一个对象，存储当前行的数据
      var rowData = {
        jianchaxiangmu: column2Value,
        shijian: column3Value,
        jieguo: column4Value
      };
      jianchaData.push(rowData);
    }
  }


  //下面是上传参考图片的代码
  const imgsInput = document.getElementById('imgsInput');
  const fileListElement = document.getElementById('fileList');
  const previewContainer = document.getElementById('previewContainer');
  const previewImage = document.getElementById('previewImage');

  imgsInput.addEventListener('change', updateFileList);

  function updateFileList() {
    const files = imgsInput.files;
    for (let i = 0; i < files.length; i++) {
      const fileName = files[i].name;
      cankao.push(files[i]); // 将文件添加到数组中

      const row = document.createElement('tr');
      const nameCell = document.createElement('td');
      const deleteCell = document.createElement('td');
      const previewCell = document.createElement('td');

      nameCell.textContent = fileName;
      row.appendChild(nameCell);

      const deleteLink = document.createElement('a');
      deleteLink.textContent = '删除';
      deleteLink.href = '#'; // 设置为 '#'，防止页面跳转
      deleteLink.addEventListener('click', () => deleteRowAndFile(i, row));
      deleteCell.appendChild(deleteLink);
      row.appendChild(deleteCell);

      const previewLink = document.createElement('a');
      previewLink.textContent = '预览';
      previewLink.href = '#'; // 设置为 '#'，防止页面跳转
      previewLink.addEventListener('click', () => showPreview(files[i]));
      previewCell.appendChild(previewLink);
      row.appendChild(previewCell);

      fileListElement.appendChild(row);
    }
  }

  function deleteRowAndFile(index, row) {
    cankao.splice(index, 1); // 删除数组中的对应文件名
    fileListElement.removeChild(row); // 删除表格中的对应行
  }

  function showPreview(file) {
    previewImage.src = URL.createObjectURL(file);
    previewContainer.style.display = 'block';
  }

  function closePreview() {
    previewImage.src = '';
    previewContainer.style.display = 'none';
  }

</script>

<!--该script是关于舌脉的点击与表格的-->
<script>
  var selectedOptions = [];
  var rowCount = 1;

  $(document).ready(function () {
    $("input[name^='shese'], input[name^='shexing'], input[name^='shetai'], input[name^='taizhi'], input[name^='taise']").on("change", function () {
      updateSelectedOptions($(this).attr('name'), $(this).val(), this.checked);
      updateTable();
    });
  });
  function updateSelectedOptions(category, option, isChecked) {
    if (isChecked) {
      selectedOptions.push({ name: category, value: option });
    } else {
      selectedOptions = selectedOptions.filter(function (item) {
        return !(item.name === category && item.value === option);
      });
    }
  }

  function updateTable() {
    var table = $("#resultTable");
    table.find("tr:not(:first-child)").remove();
    rowCount = 1; // 重置序号为1
    for (var i = 0; i < selectedOptions.length; i++) {
      var checkName=selectedOptions[i].name,tempName;
      if(checkName=='shese'){
        tempName='舌色';
      }
      else if(checkName=='shexing'){
        tempName='舌形';
      }
      else if(checkName=='shetai'){
        tempName='舌态';
      }
      else if(checkName=='taizhi'){
        tempName='苔质';
      }
      else if(checkName=='自定义') {
        tempName='自定义';
      }
      else{
        tempName='苔色';
      }
      var row = $("<tr class='row-num'><td>" + rowCount + "</td><td>" +tempName + "</td><td>" + selectedOptions[i].value + "</td></tr>");
      table.append(row);
      rowCount++;
    }
  }

  function addCustomOption() {
    var userInput = $("#userInput").val().trim();
    if (userInput !== '') {
      document.getElementById('userInput').value='';
      selectedOptions.push({ name: "自定义", value: userInput });
      updateTable();
    }
  }
  function addEnter_2(event){
    // 检查按下的按键是否为回车键，回车键的keyCode是13
    if (event.keyCode === 13) {
      addCustomOption();
    }
  }
  function clearTable_2() {
    selectedOptions = [];
    rowCount = 1;
    $("input[name^='shese'], input[name^='shexing'], input[name^='shetai'], input[name^='taizhi'], input[name^='taise']").prop("checked", false);
    updateTable();
  }
</script>
<!--以下是关于脉象的js代码-->
<script>
  var selectedOptions_M = [];
  var rowNum_M = 1;

  // 更新选中的多选框值
  function updateSelection_M(option) {
    var index = selectedOptions_M.indexOf(option);
    if (index === -1) {
      selectedOptions_M.push(option);
    } else {
      selectedOptions_M.splice(index, 1);
    }
  }

  // 添加到表格
  function addToTable_M() {
    var userInputText = document.getElementById('userInputText').value.trim();
    var resultTable_2 = document.getElementById('resultTable_2');
    var tableBody = document.getElementById('tableBody_M');

    if (userInputText !== '') {
      // 将用户输入的文本添加到表格中
      var newRow = tableBody.insertRow();
      var indexCell = newRow.insertCell();
      var contentCell = newRow.insertCell();

      indexCell.textContent = rowNum_M;
      rowNum_M++;

      contentCell.textContent = userInputText;
      // 清空用户输入文本框
      document.getElementById('userInputText').value = '';
    }
    else if (selectedOptions_M.length > 0) {
      // 将多选框的值按点击顺序添加到表格中
      var newRow = tableBody.insertRow();
      var indexCell = newRow.insertCell();
      var contentCell = newRow.insertCell();

      indexCell.textContent = rowNum_M;
      rowNum_M++;

      contentCell.textContent = selectedOptions_M.join('');

      // 清空多选框选中记录
      var checkboxes = document.querySelectorAll('input[name^="fumai"]');
      for (var i = 0; i < checkboxes.length; i++) {
        checkboxes[i].checked = false;
      }
      selectedOptions_M = [];
    }
  }

  // 清空表格和序号
  function clearTable_M() {
    var resultTable_2 = document.getElementById('resultTable_2');
    var tableBody = document.getElementById('tableBody_M');
    tableBody.innerHTML = ''; // 清空表格内容
    rowNum_M = 1; // 重置序号为1
  }
</script>

